| @@ 5-47 (lines=43) @@ | ||
| 2 | ||
| 3 | namespace Enzyme\Loopy\Filters; |
|
| 4 | ||
| 5 | class Greater implements FilterInterface |
|
| 6 | { |
|
| 7 | /** |
|
| 8 | * The rule to test against. |
|
| 9 | * |
|
| 10 | * @var mixed |
|
| 11 | */ |
|
| 12 | protected $rule; |
|
| 13 | ||
| 14 | /** |
|
| 15 | * Wether or not to test greater than or equal too. |
|
| 16 | * |
|
| 17 | * @var boolean |
|
| 18 | */ |
|
| 19 | protected $or_equal; |
|
| 20 | ||
| 21 | /** |
|
| 22 | * Create a new Greater filter given the value to test against |
|
| 23 | * and whether to perform a greater than or equal too check. |
|
| 24 | * |
|
| 25 | * @param mixed $rule The value to check against. |
|
| 26 | * @param boolean $or_equal Whether to perform greater than or equal too. |
|
| 27 | */ |
|
| 28 | public function __construct($rule, $or_equal = false) |
|
| 29 | { |
|
| 30 | $this->rule = $rule; |
|
| 31 | $this->or_equal = $or_equal; |
|
| 32 | } |
|
| 33 | ||
| 34 | /** |
|
| 35 | * {@inheritdoc} |
|
| 36 | */ |
|
| 37 | public function passes($key, $value) |
|
| 38 | { |
|
| 39 | if (is_numeric($value) === false) { |
|
| 40 | return false; |
|
| 41 | } |
|
| 42 | ||
| 43 | return $this->or_equal === true |
|
| 44 | ? $value >= $this->rule |
|
| 45 | : $value > $this->rule; |
|
| 46 | } |
|
| 47 | } |
|
| @@ 5-47 (lines=43) @@ | ||
| 2 | ||
| 3 | namespace Enzyme\Loopy\Filters; |
|
| 4 | ||
| 5 | class Less implements FilterInterface |
|
| 6 | { |
|
| 7 | /** |
|
| 8 | * The rule to test against. |
|
| 9 | * |
|
| 10 | * @var mixed |
|
| 11 | */ |
|
| 12 | protected $rule; |
|
| 13 | ||
| 14 | /** |
|
| 15 | * Wether or not to test less than or equal too. |
|
| 16 | * |
|
| 17 | * @var boolean |
|
| 18 | */ |
|
| 19 | protected $or_equal; |
|
| 20 | ||
| 21 | /** |
|
| 22 | * Create a new Less filter given the value to test against |
|
| 23 | * and whether to perform a less than or equal too check. |
|
| 24 | * |
|
| 25 | * @param mixed $rule The value to check against. |
|
| 26 | * @param boolean $or_equal Whether to perform less than or equal too. |
|
| 27 | */ |
|
| 28 | public function __construct($rule, $or_equal = false) |
|
| 29 | { |
|
| 30 | $this->rule = $rule; |
|
| 31 | $this->or_equal = $or_equal; |
|
| 32 | } |
|
| 33 | ||
| 34 | /** |
|
| 35 | * {@inheritdoc} |
|
| 36 | */ |
|
| 37 | public function passes($key, $value) |
|
| 38 | { |
|
| 39 | if (is_numeric($value) === false) { |
|
| 40 | return false; |
|
| 41 | } |
|
| 42 | ||
| 43 | return $this->or_equal === true |
|
| 44 | ? $value <= $this->rule |
|
| 45 | : $value < $this->rule; |
|
| 46 | } |
|
| 47 | } |
|