IntegerCriteria::shouldBeApplied()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 4
ccs 2
cts 2
cp 1
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
crap 1
1
<?php
2
declare(strict_types=1);
3
4
namespace KGzocha\Searcher\Criteria;
5
6
/**
7
 * @author Krzysztof Gzocha <[email protected]>
8
 */
9
class IntegerCriteria implements CriteriaInterface
10
{
11
    /**
12
     * @var int
13
     */
14
    private $integer;
15
16
    /**
17
     * @param int $integer
18
     */
19 5
    public function __construct(int $integer = null)
20
    {
21 5
        $this->integer = $integer;
22 5
    }
23
24
    /**
25
     * @return int|null
26
     */
27 1
    public function getInteger()
28
    {
29 1
        return $this->integer;
30
    }
31
32
    /**
33
     * @param int $integer
34
     */
35 1
    public function setInteger(int $integer = null)
36
    {
37 1
        $this->integer = $integer;
38 1
    }
39
40
    /**
41
     * {@inheritdoc}
42
     */
43 3
    public function shouldBeApplied(): bool
44
    {
45 3
        return $this->integer !== null;
46
    }
47
}
48