1 | <?php |
||
12 | abstract class AbstractRange implements RangeInterface |
||
13 | { |
||
14 | /** |
||
15 | * Range minimum value. |
||
16 | * |
||
17 | * @var int |
||
18 | */ |
||
19 | private $min; |
||
20 | |||
21 | /** |
||
22 | * Range maximum value. |
||
23 | * |
||
24 | * @var int |
||
25 | */ |
||
26 | private $max; |
||
27 | |||
28 | /** |
||
29 | * Range constructor. |
||
30 | * |
||
31 | * @param int $min |
||
32 | * @param int $max |
||
33 | */ |
||
34 | public function __construct($min, $max) |
||
35 | { |
||
36 | if ( |
||
37 | 15 | 2 !== count(array_filter([$min, $max], function ($value) { |
|
38 | 15 | return true === is_int($value); |
|
39 | 15 | })) |
|
40 | 5 | ) { |
|
41 | 6 | throw new \InvalidArgumentException( |
|
42 | 4 | 'All parameters at Size object must be integers.' |
|
43 | 2 | ); |
|
44 | } |
||
45 | |||
46 | 9 | if ($min > $max) { |
|
47 | 3 | throw new \InvalidArgumentException( |
|
48 | 2 | 'Min value must be greater than ma value.' |
|
49 | 1 | ); |
|
50 | } |
||
51 | |||
52 | 6 | $this->min = $min; |
|
53 | 6 | $this->max = $max; |
|
54 | 6 | } |
|
55 | |||
56 | /** |
||
57 | * Get Range min value. |
||
58 | * |
||
59 | * @return int |
||
60 | */ |
||
61 | 3 | public function getMin() |
|
65 | |||
66 | /** |
||
67 | * Get Range max value. |
||
68 | * |
||
69 | * @return int |
||
70 | */ |
||
71 | 3 | public function getMax() |
|
75 | } |
||
76 |