Completed
Push — master ( bf71a3...ce0169 )
by Nikolas
03:09
created

RangeType::getStep()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 3
rs 10
cc 1
eloc 2
nc 1
nop 0
1
<?php
2
namespace rtens\domin\reflection\types;
3
4
use watoki\reflect\Type;
5
use watoki\reflect\type\IntegerType;
6
7
class RangeType extends IntegerType {
8
9
    /** @var int */
10
    private $min;
11
12
    /** @var int */
13
    private $max;
14
15
    /** @var int */
16
    private $step;
17
18
    /**
19
     * @param int $min
20
     * @param int $max
21
     * @param int $step
22
     */
23
    public function __construct($min, $max, $step = 1) {
24
        $this->min = $min;
25
        $this->max = $max;
26
        $this->step = $step;
27
    }
28
29
    /**
30
     * @return int
31
     */
32
    public function getMin() {
33
        return $this->min;
34
    }
35
36
    /**
37
     * @return int
38
     */
39
    public function getMax() {
40
        return $this->max;
41
    }
42
43
    /**
44
     * @return int
45
     */
46
    public function getStep() {
47
        return $this->step;
48
    }
49
50
    /**
51
     * @param mixed $value
52
     * @return boolean
53
     */
54
    public function is($value) {
55
        return parent::is($value) && $value >= $this->min && $value <= $this->max;
56
    }
57
58
    /**
59
     * @return string
60
     */
61
    public function __toString() {
62
        return "[{$this->min};{$this->max};{$this->step}]";
63
    }
64
}