Completed
Push — master ( f15ae2...696b4c )
by Yaro
04:13 queued 11s
created

MinMaxStep::hasMin()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 4
ccs 0
cts 2
cp 0
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
crap 2
1
<?php
2
3
namespace Yaro\Jarboe\Table\Fields\Traits;
4
5
trait MinMaxStep
6
{
7
    /**
8
     * @var null|float
9
     */
10
    private $min = null;
11
12
    /**
13
     * @var null|float
14
     */
15
    private $max = null;
16
17
    /**
18
     * @var string|float
19
     */
20
    private $step = 'any';
21
22
    /**
23
     * Set value for `min` attribute.
24
     *
25
     * @param float $min
26
     * @return $this
27
     */
28
    public function min(float $min)
29
    {
30
        $this->min = $min;
31
32
        return $this;
33
    }
34
35
    /**
36
     * Set value for `max` attribute.
37
     *
38
     * @param float $max
39
     * @return $this
40
     */
41
    public function max(float $max)
42
    {
43
        $this->max = $max;
44
45
        return $this;
46
    }
47
48
    /**
49
     * Set value for `step` attribute. Default is `any`.
50
     *
51
     * @param float $step
52
     * @return $this
53
     */
54
    public function step(float $step)
55
    {
56
        $this->step = $step;
57
58
        return $this;
59
    }
60
61
    /**
62
     * Check if `min` attribute values specified.
63
     *
64
     * @return bool
65
     */
66
    public function hasMin(): bool
67
    {
68
        return !is_null($this->min);
69
    }
70
71
    /**
72
     * Check if `max` attribute values specified.
73
     *
74
     * @return bool
75
     */
76
    public function hasMax(): bool
77
    {
78
        return !is_null($this->max);
79
    }
80
81
    /**
82
     * Retrieve `min` attribute value.
83
     *
84
     * @return null|float
85
     */
86
    public function getMin(): ?float
87
    {
88
        return $this->min;
89
    }
90
91
    /**
92
     * Retrieve `min` attribute value.
93
     *
94
     * @return null|float
95
     */
96
    public function getMax(): ?float
97
    {
98
        return $this->max;
99
    }
100
101
    /**
102
     * Retrieve `step` attribute value.
103
     *
104
     * @return float|string
105
     */
106
    public function getStep()
107
    {
108
        return $this->step;
109
    }
110
}
111