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()
56
56
$ this ->find ()->shouldHaveType ('spec\Http\Discovery\AnotherClassToFind ' );
57
57
}
58
58
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
+
59
81
function it_registers_a_class_with_an_invalid_condition ()
60
82
{
61
83
$ this ->reset ();
Original file line number Diff line number Diff line change @@ -68,6 +68,15 @@ protected static function evaluateCondition($condition)
68
68
return $ condition ();
69
69
} elseif (is_bool ($ condition )) {
70
70
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 ;
71
80
}
72
81
73
82
return false ;
You can’t perform that action at this time.
0 commit comments