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

RangeType   A

Complexity

Total Complexity 8

Size/Duplication

Total Lines 58
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 8
c 1
b 0
f 0
lcom 1
cbo 1
dl 0
loc 58
rs 10

6 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 5 1
A getMin() 0 3 1
A getMax() 0 3 1
A getStep() 0 3 1
A is() 0 3 3
A __toString() 0 3 1
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
}