phpat
phpat copied to clipboard
Add combination operators to selectors
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();