ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
Minimum.php
Go to the documentation of this file.
1<?php
2
4
6
7class Minimum extends MaxMinBase
8{
22 public static function min(...$args)
23 {
24 $returnValue = null;
25
26 // Loop through arguments
27 $aArgs = Functions::flattenArray($args);
28 foreach ($aArgs as $arg) {
29 // Is it a numeric value?
30 if ((is_numeric($arg)) && (!is_string($arg))) {
31 if (($returnValue === null) || ($arg < $returnValue)) {
32 $returnValue = $arg;
33 }
34 }
35 }
36
37 if ($returnValue === null) {
38 return 0;
39 }
40
41 return $returnValue;
42 }
43
56 public static function minA(...$args)
57 {
58 $returnValue = null;
59
60 // Loop through arguments
61 $aArgs = Functions::flattenArray($args);
62 foreach ($aArgs as $arg) {
63 // Is it a numeric value?
64 if ((is_numeric($arg)) || (is_bool($arg)) || ((is_string($arg) && ($arg != '')))) {
66 if (($returnValue === null) || ($arg < $returnValue)) {
67 $returnValue = $arg;
68 }
69 }
70 }
71
72 if ($returnValue === null) {
73 return 0;
74 }
75
76 return $returnValue;
77 }
78}
An exception for terminatinating execution or to throw for unit testing.
static flattenArray($array)
Convert a multi-dimensional array to a simple 1-dimensional array.
Definition: Functions.php:583