Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add combination operators to selectors #186

Closed
gplanchat opened this issue Jun 15, 2022 · 1 comment
Closed

Add combination operators to selectors #186

gplanchat opened this issue Jun 15, 2022 · 1 comment
Labels
enhancement New feature or request

Comments

@gplanchat
Copy link

gplanchat commented Jun 15, 2022

Enhancement description
While defining my rules, I need to define some fine grained rules such as:

  • If class implements interface X, I want it to use trait A or B or C
  • if class uses trait A, I want its class to implement interface A and one of ( B or C )

Currently, all rules are combining as an and operator.
Those operators may be useful:

  • all of (and operator)
  • any of (or operator)
  • none of (not operator)
  • one of (xor operator)
  • at least X of
  • at most X of

Suggested approach or solution
By creating new selectors, I can now define more precise rules

$this->newRule
    ->classesThat(Selector::implementInterface('EventSauce\EventSourcing\AggregateRoot'))
    ->mustInclude()
    ->classesThat(
        Selector::oneOf(
            Selector::haveClassName('EventSauce\EventSourcing\AggregateRootWithAggregates'),
            Selector::haveClassName('EventSauce\EventSourcing\AggregateRootBehaviour'),
            Selector::haveClassName('EventSauce\EventSourcing\AggregateAlwaysAppliesEvents'),
        )
    )
    ->build();
@gplanchat gplanchat added the enhancement New feature or request label Jun 15, 2022
gplanchat added a commit to gplanchat/phpat that referenced this issue Jun 15, 2022
gplanchat added a commit to gplanchat/phpat that referenced this issue Jun 15, 2022
@carlosas
Copy link
Owner

carlosas commented Jan 5, 2025

@carlosas carlosas closed this as completed Jan 5, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants