Less::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 5
Ratio 100 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
c 1
b 0
f 1
dl 5
loc 5
rs 9.4285
cc 1
eloc 3
nc 1
nop 2
1
<?php
2
3
namespace Enzyme\Loopy\Filters;
4
5 View Code Duplication
class Less implements FilterInterface
0 ignored issues
show
Duplication introduced by
This class seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
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
}