We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 001d465 commit 2712866Copy full SHA for 2712866
src/TrinaryLogic.php
@@ -240,11 +240,15 @@ public static function lazyExtremeIdentity(
240
*/
241
public static function maxMin(self ...$operands): self
242
{
243
- if ($operands === []) {
244
- throw new ShouldNotHappenException();
+ $max = self::NO;
+ $min = self::YES;
245
+ foreach ($operands as $operand) {
246
+ $max |= $operand->value;
247
+ $min &= $operand->value;
248
}
- $operandValues = array_column($operands, 'value');
- return self::create(max($operandValues) > self::MAYBE ? self::YES : min($operandValues));
249
+ $maxMin = $max === self::YES ? self::YES : $min;
250
+
251
+ return self::$registry[$maxMin] ??= new self($maxMin);
252
253
254
/**
0 commit comments