Greater::passes()   A
last analyzed

Complexity

Conditions 3
Paths 3

Size

Total Lines 10
Code Lines 6

Duplication

Lines 10
Ratio 100 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
c 1
b 0
f 1
dl 10
loc 10
rs 9.4285
cc 3
eloc 6
nc 3
nop 2
1
<?php
2
3
namespace Enzyme\Loopy\Filters;
4
5 View Code Duplication
class Greater 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 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
}