Skip to content

Commit

Permalink
refactor(docblocks): document public apis/methods
Browse files Browse the repository at this point in the history
  • Loading branch information
adhocore committed Aug 15, 2018
1 parent ee2cc96 commit d73a078
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions src/Validator.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,29 @@
*/
class Validator
{
/**
* Check if the value is in range of given offset.
*
* @param int $value
* @param string $offset
*
* @return bool
*/
public function inRange($value, $offset)
{
$parts = \explode('-', $offset);

return $parts[0] <= $value && $value <= $parts[1];
}

/**
* Check if the value is in step of given offset.
*
* @param int $value
* @param string $offset
*
* @return bool
*/
public function inStep($value, $offset)
{
$parts = \explode('/', $offset, 2);
Expand All @@ -45,6 +61,16 @@ public function inStep($value, $offset)
return $this->inStepRange($value, $subparts[0], $subparts[1], $parts[1]);
}

/**
* Check if the value falls between start and end when advanved by step.
*
* @param int $value
* @param int $start
* @param int $end
* @param int $step
*
* @return bool
*/
public function inStepRange($value, $start, $end, $step)
{
if (($start + $step) > $end) {
Expand Down

0 comments on commit d73a078

Please sign in to comment.