File tree Expand file tree Collapse file tree 2 files changed +31
-0
lines changed
Expand file tree Collapse file tree 2 files changed +31
-0
lines changed Original file line number Diff line number Diff line change @@ -56,6 +56,28 @@ function it_registers_a_class_with_a_boolean_condition()
5656 $ this ->find ()->shouldHaveType ('spec\Http\Discovery\AnotherClassToFind ' );
5757 }
5858
59+ function it_registers_a_class_with_an_array_condition ()
60+ {
61+ $ this ->reset ();
62+
63+ $ this ->register (
64+ 'spec\Http\Discovery\AnotherClassToFind ' ,
65+ [
66+ true ,
67+ 'spec\Http\Discovery\AnotherClassToFind ' ,
68+ ]
69+ );
70+ $ this ->register (
71+ 'spec\Http\Discovery\ClassToFind ' ,
72+ [
73+ false ,
74+ 'spec\Http\Discovery\ClassToFind ' ,
75+ ]
76+ );
77+
78+ $ this ->find ()->shouldHaveType ('spec\Http\Discovery\AnotherClassToFind ' );
79+ }
80+
5981 function it_registers_a_class_with_an_invalid_condition ()
6082 {
6183 $ this ->reset ();
Original file line number Diff line number Diff line change @@ -68,6 +68,15 @@ protected static function evaluateCondition($condition)
6868 return $ condition ();
6969 } elseif (is_bool ($ condition )) {
7070 return $ condition ;
71+ } elseif (is_array ($ condition )) {
72+ $ evaluatedCondition = true ;
73+
74+ // Immediately stop execution if the condition is false
75+ for ($ i = 0 ; $ i < count ($ condition ) && false !== $ evaluatedCondition ; $ i ++) {
76+ $ evaluatedCondition &= static ::evaluateCondition ($ condition [$ i ]);
77+ }
78+
79+ return $ evaluatedCondition ;
7180 }
7281
7382 return false ;
You can’t perform that action at this time.
0 commit comments