File tree Expand file tree Collapse file tree 2 files changed +26
-2
lines changed
Expand file tree Collapse file tree 2 files changed +26
-2
lines changed Original file line number Diff line number Diff line change @@ -163,14 +163,26 @@ public static function lazyMaxMin(
163163 ): self
164164 {
165165 $ results = [];
166+ $ reasons = [];
167+ $ hasNo = false ;
166168 foreach ($ objects as $ object ) {
167169 $ isAcceptedBy = $ callback ($ object );
168170 if ($ isAcceptedBy ->result ->yes ()) {
169171 return $ isAcceptedBy ;
172+ } elseif ($ isAcceptedBy ->result ->no ()) {
173+ $ hasNo = true ;
170174 }
171175 $ results [] = $ isAcceptedBy ;
176+
177+ foreach ($ isAcceptedBy ->reasons as $ reason ) {
178+ $ reasons [] = $ reason ;
179+ }
172180 }
173- return self ::maxMin (...$ results );
181+
182+ return new self (
183+ $ hasNo ? TrinaryLogic::createNo () : TrinaryLogic::createMaybe (),
184+ array_values (array_unique ($ reasons )),
185+ );
174186 }
175187
176188}
Original file line number Diff line number Diff line change @@ -196,14 +196,26 @@ public static function lazyMaxMin(
196196 ): self
197197 {
198198 $ results = [];
199+ $ reasons = [];
200+ $ hasNo = false ;
199201 foreach ($ objects as $ object ) {
200202 $ isSuperTypeOf = $ callback ($ object );
201203 if ($ isSuperTypeOf ->result ->yes ()) {
202204 return $ isSuperTypeOf ;
205+ } elseif ($ isSuperTypeOf ->result ->no ()) {
206+ $ hasNo = true ;
203207 }
204208 $ results [] = $ isSuperTypeOf ;
209+
210+ foreach ($ isSuperTypeOf ->reasons as $ reason ) {
211+ $ reasons [] = $ reason ;
212+ }
205213 }
206- return self ::maxMin (...$ results );
214+
215+ return new self (
216+ $ hasNo ? TrinaryLogic::createNo () : TrinaryLogic::createMaybe (),
217+ array_values (array_unique ($ reasons )),
218+ );
207219 }
208220
209221 public function negate (): self
You can’t perform that action at this time.
0 commit comments