@@ 71-82 (lines=12) @@ | ||
68 | * |
|
69 | * @return \Closure |
|
70 | */ |
|
71 | public static function min() |
|
72 | { |
|
73 | return function ($a, $b) { |
|
74 | if (!(is_numeric($a) || $a instanceof \DateTime)) { |
|
75 | throw new \InvalidArgumentException(sprintf('Argument $A must be numeric to determine minimum, not %s', is_object($a) ? get_class($a) : gettype($a))); |
|
76 | } |
|
77 | if (!(is_numeric($b) || $b instanceof \DateTime)) { |
|
78 | throw new \InvalidArgumentException(sprintf('Argument $B must be numeric to determine minimum, not %s', is_object($b) ? get_class($b) : gettype($b))); |
|
79 | } |
|
80 | return $a < $b ? $a : $b; |
|
81 | }; |
|
82 | } |
|
83 | ||
84 | /** |
|
85 | * Returns a closure that returns the largest of two numbers |
|
@@ 89-100 (lines=12) @@ | ||
86 | * |
|
87 | * @return \Closure |
|
88 | */ |
|
89 | public static function max() |
|
90 | { |
|
91 | return function ($a, $b) { |
|
92 | if (!(is_numeric($a) || $a instanceof \DateTime)) { |
|
93 | throw new \InvalidArgumentException(sprintf('Argument $A must be numeric to determine maximum, not %s', is_object($a) ? get_class($a) : gettype($a))); |
|
94 | } |
|
95 | if (!(is_numeric($b) || $b instanceof \DateTime)) { |
|
96 | throw new \InvalidArgumentException(sprintf('Argument $B must be numeric to determine maximum, not %s', is_object($b) ? get_class($b) : gettype($b))); |
|
97 | } |
|
98 | return $a < $b ? $b : $a; |
|
99 | }; |
|
100 | } |
|
101 | ||
102 | /** |
|
103 | * Returns a closure that concatenates two strings using $glue |