AboveRule::getMinimum()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 4
Ratio 100 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
cc 1
nc 1
nop 0
dl 4
loc 4
ccs 2
cts 2
cp 1
crap 1
rs 10
c 0
b 0
f 0
1
<?php
2
namespace JClaveau\LogicalFilter\Rule;
3
4
/**
5
 * a > x
6
 */
7 View Code Duplication
class AboveRule extends AbstractAtomicRule
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...
8
{
9
    /** @var string operator */
10
    const operator = '>';
11
12
    /** @var scalar $minimum */
13
    protected $minimum;
14
15
    /**
16
     * @param string $field The field to apply the rule on.
17
     * @param array  $value The value the field can above to.
0 ignored issues
show
Bug introduced by
There is no parameter named $value. Was it maybe removed?

This check looks for PHPDoc comments describing methods or function parameters that do not exist on the corresponding method or function.

Consider the following example. The parameter $italy is not defined by the method finale(...).

/**
 * @param array $germany
 * @param array $island
 * @param array $italy
 */
function finale($germany, $island) {
    return "2:1";
}

The most likely cause is that the parameter was removed, but the annotation was not.

Loading history...
18
     */
19 140
    public function __construct( $field, $minimum )
20
    {
21 140
        if (   ! is_scalar($minimum)
22 140
            && ! $minimum instanceof \DateTimeInterface
23 140
            && null !== $minimum
24 140
        ) {
25 1
            throw new \InvalidArgumentException(
26
                "Minimum parameter must be a scalar or null "
27
                ."or implements DateTimeInterface instead of: "
28 1
                .var_export($minimum, true)
29 1
            );
30
        }
31
32 140
        $this->field   = $field;
33 140
        $this->minimum = $minimum;
34 140
    }
35
36
    /**
37
     * @deprecated getLowerLimit
38
     */
39 130
    public function getMinimum()
40
    {
41 130
        return $this->minimum;
42
    }
43
44
    /**
45
     */
46 42
    public function getLowerLimit()
47
    {
48 42
        return $this->minimum;
49
    }
50
51
    /**
52
     * @return array
0 ignored issues
show
Documentation introduced by
Should the return type not be integer|double|string|boolean?

This check compares the return type specified in the @return annotation of a function or method doc comment with the types returned by the function and raises an issue if they mismatch.

Loading history...
53
     */
54 130
    public function getValues()
55
    {
56 130
        return $this->getMinimum();
0 ignored issues
show
Deprecated Code introduced by
The method JClaveau\LogicalFilter\R...AboveRule::getMinimum() has been deprecated with message: getLowerLimit

This method has been deprecated. The supplier of the class has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the method will be removed from the class and what other method or class to use instead.

Loading history...
57
    }
58
59
    /**
60
     * Checks if the rule do not expect the value to be above infinity.
61
     *
62
     * @return bool
63
     */
64 42
    public function hasSolution(array $simplification_options=[])
65
    {
66
        // if minimum is null, the rule is equivalent to true
67 42
        if (is_numeric( $this->minimum )) {
68 30
            if (is_nan( $this->minimum )) {
69 2
                return false;
70
            }
71
72 30
            if (is_infinite( $this->minimum ) && $this->minimum > 0) {
73 2
                return false;
74
            }
75 30
        }
76
77 42
        return true;
78
    }
79
80
    /**/
81
}
82