Less   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 43
Duplicated Lines 100 %

Coupling/Cohesion

Components 1
Dependencies 0

Importance

Changes 1
Bugs 0 Features 1
Metric Value
wmc 4
c 1
b 0
f 1
lcom 1
cbo 0
dl 43
loc 43
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 5 5 1
A passes() 10 10 3

How to fix   Duplicated Code   

Duplicated Code

Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.

Common duplication problems, and corresponding solutions are:

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
}