Completed
Push — master ( 3485f9...8fe415 )
by Koldo
14:45
created

AbstractRange   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 58
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Importance

Changes 0
Metric Value
wmc 4
lcom 0
cbo 0
dl 0
loc 58
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 15 2
A getMin() 0 4 1
A getMax() 0 4 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
            2 !== count(array_filter([$min, $max], function ($value) {
38
                return true === is_int($value);
39
            }))
40
        ) {
41
            throw new \InvalidArgumentException(
42
                'All parameters at Size object must be integers.'
43
            );
44
        }
45
46
        $this->min = $min;
47
        $this->max = $max;
48
    }
49
50
    /**
51
     * Get Range min value.
52
     *
53
     * @return int
54
     */
55
    public function getMin()
56
    {
57
        return $this->min;
58
    }
59
60
    /**
61
     * Get Range max value.
62
     *
63
     * @return int
64
     */
65
    public function getMax()
66
    {
67
        return $this->max;
68
    }
69
}
70