File tree 2 files changed +14
-9
lines changed
2 files changed +14
-9
lines changed Original file line number Diff line number Diff line change @@ -17,14 +17,17 @@ public function __construct(SpecificationInterface ...$specifications)
17
17
$ this ->specifications = $ specifications ;
18
18
}
19
19
20
+ /**
21
+ * if at least one specification is false, return false, else return true.
22
+ */
20
23
public function isSatisfiedBy (Item $ item ): bool
21
24
{
22
- $ satisfied = [];
23
-
24
25
foreach ($ this ->specifications as $ specification ) {
25
- $ satisfied [] = $ specification ->isSatisfiedBy ($ item );
26
+ if (!$ specification ->isSatisfiedBy ($ item )) {
27
+ return false ;
28
+ }
26
29
}
27
30
28
- return ! in_array ( false , $ satisfied ) ;
31
+ return true ;
29
32
}
30
33
}
Original file line number Diff line number Diff line change @@ -17,14 +17,16 @@ public function __construct(SpecificationInterface ...$specifications)
17
17
$ this ->specifications = $ specifications ;
18
18
}
19
19
20
+ /**
21
+ * if at least one specification is true, return true, else return false
22
+ */
20
23
public function isSatisfiedBy (Item $ item ): bool
21
24
{
22
- $ satisfied = [];
23
-
24
25
foreach ($ this ->specifications as $ specification ) {
25
- $ satisfied [] = $ specification ->isSatisfiedBy ($ item );
26
+ if ($ specification ->isSatisfiedBy ($ item )) {
27
+ return true ;
28
+ }
26
29
}
27
-
28
- return in_array (true , $ satisfied );
30
+ return false ;
29
31
}
30
32
}
You can’t perform that action at this time.
0 commit comments