Test Failed
Push — master ( 14bb9e...d96886 )
by Jean
04:16
created

AboveRule::getLowerLimit()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 0
dl 0
loc 3
rs 10
c 0
b 0
f 0
1
<?php
2
namespace JClaveau\LogicalFilter\Rule;
3
4
/**
5
 * a > x
6
 */
7
class AboveRule extends AbstractAtomicRule
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.
18
     */
19
    public function __construct( $field, $minimum )
20
    {
21
        if (    !is_scalar($minimum)
22
            &&  !$minimum instanceof \DateTimeInterface
23
            &&  null !== $minimum
24
        ) {
25
            throw new \InvalidArgumentException(
26
                "Minimum parameter must be a scalar or null "
27
                ."or implements DateTimeInterface instead of: "
28
                .var_export($minimum, true)
29
            );
30
        }
31
32
        $this->field   = $field;
33
        $this->minimum = $minimum;
34
    }
35
36
    /**
37
     * @deprecated getLowerLimit
38
     */
39
    public function getMinimum()
40
    {
41
        return $this->minimum;
42
    }
43
44
    /**
45
     */
46
    public function getLowerLimit()
47
    {
48
        return $this->minimum;
49
    }
50
51
    /**
52
     * @return array
53
     */
54
    public function getValues()
55
    {
56
        return $this->getMinimum();
0 ignored issues
show
Deprecated Code introduced by
The function JClaveau\LogicalFilter\R...AboveRule::getMinimum() has been deprecated: getLowerLimit ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-deprecated  annotation

56
        return /** @scrutinizer ignore-deprecated */ $this->getMinimum();

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

The explanatory message should give you some clue as to whether and when the function will be removed and what other function 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
    public function hasSolution(array $simplification_options=[])
0 ignored issues
show
Unused Code introduced by
The parameter $simplification_options is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

64
    public function hasSolution(/** @scrutinizer ignore-unused */ array $simplification_options=[])

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
65
    {
66
        // if minimum is null, the rule is equivalent to true
67
        if (is_numeric( $this->minimum )) {
68
            if (is_nan( $this->minimum ))
0 ignored issues
show
Bug introduced by
It seems like $this->minimum can also be of type string; however, parameter $val of is_nan() does only seem to accept double, maybe add an additional type check? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

68
            if (is_nan( /** @scrutinizer ignore-type */ $this->minimum ))
Loading history...
69
                return false;
70
71
            if (is_infinite( $this->minimum ) && $this->minimum > 0)
0 ignored issues
show
Bug introduced by
It seems like $this->minimum can also be of type string; however, parameter $val of is_infinite() does only seem to accept double, maybe add an additional type check? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

71
            if (is_infinite( /** @scrutinizer ignore-type */ $this->minimum ) && $this->minimum > 0)
Loading history...
72
                return false;
73
        }
74
75
        return true;
76
    }
77
78
    /**/
79
}
80