File tree Expand file tree Collapse file tree 1 file changed +26
-0
lines changed Expand file tree Collapse file tree 1 file changed +26
-0
lines changed Original file line number Diff line number Diff line change 20
20
*/
21
21
class Validator
22
22
{
23
+ /**
24
+ * Check if the value is in range of given offset.
25
+ *
26
+ * @param int $value
27
+ * @param string $offset
28
+ *
29
+ * @return bool
30
+ */
23
31
public function inRange ($ value , $ offset )
24
32
{
25
33
$ parts = \explode ('- ' , $ offset );
26
34
27
35
return $ parts [0 ] <= $ value && $ value <= $ parts [1 ];
28
36
}
29
37
38
+ /**
39
+ * Check if the value is in step of given offset.
40
+ *
41
+ * @param int $value
42
+ * @param string $offset
43
+ *
44
+ * @return bool
45
+ */
30
46
public function inStep ($ value , $ offset )
31
47
{
32
48
$ parts = \explode ('/ ' , $ offset , 2 );
@@ -45,6 +61,16 @@ public function inStep($value, $offset)
45
61
return $ this ->inStepRange ($ value , $ subparts [0 ], $ subparts [1 ], $ parts [1 ]);
46
62
}
47
63
64
+ /**
65
+ * Check if the value falls between start and end when advanved by step.
66
+ *
67
+ * @param int $value
68
+ * @param int $start
69
+ * @param int $end
70
+ * @param int $step
71
+ *
72
+ * @return bool
73
+ */
48
74
public function inStepRange ($ value , $ start , $ end , $ step )
49
75
{
50
76
if (($ start + $ step ) > $ end ) {
You can’t perform that action at this time.
0 commit comments