AbstractRange::getMin()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
c 0
b 0
f 0
dl 0
loc 4
ccs 2
cts 2
cp 1
rs 10
cc 1
eloc 2
nc 1
nop 0
crap 1
1
<?php
2
3
/**
4
 * This file is part of InFw\Range package.
5
 */
6
7
namespace InFw\Range;
8
9
/**
10
 * Class AbstractRange.
11
 */
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()
62
    {
63 3
        return $this->min;
64
    }
65
66
    /**
67
     * Get Range max value.
68
     *
69
     * @return int
70
     */
71 3
    public function getMax()
72
    {
73 3
        return $this->max;
74
    }
75
}
76