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 2020 */
2121class Validator
2222{
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+ */
2331 public function inRange ($ value , $ offset )
2432 {
2533 $ parts = \explode ('- ' , $ offset );
2634
2735 return $ parts [0 ] <= $ value && $ value <= $ parts [1 ];
2836 }
2937
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+ */
3046 public function inStep ($ value , $ offset )
3147 {
3248 $ parts = \explode ('/ ' , $ offset , 2 );
@@ -45,6 +61,16 @@ public function inStep($value, $offset)
4561 return $ this ->inStepRange ($ value , $ subparts [0 ], $ subparts [1 ], $ parts [1 ]);
4662 }
4763
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+ */
4874 public function inStepRange ($ value , $ start , $ end , $ step )
4975 {
5076 if (($ start + $ step ) > $ end ) {
You can’t perform that action at this time.
0 commit comments