Completed
Push — master ( afdd3e...7aa26d )
by Krzysztof
02:29
created

NumberCriteria   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 40
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Test Coverage

Coverage 100%

Importance

Changes 2
Bugs 0 Features 0
Metric Value
wmc 5
c 2
b 0
f 0
lcom 1
cbo 0
dl 0
loc 40
ccs 11
cts 11
cp 1
rs 10

4 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A shouldBeApplied() 0 5 2
A getNumber() 0 4 1
A setNumber() 0 4 1
1
<?php
2
3
namespace KGzocha\Searcher\Criteria;
4
5
/**
6
 * @author Krzysztof Gzocha <[email protected]>
7
 */
8
class NumberCriteria implements CriteriaInterface
9
{
10
    /**
11
     * @var float
12
     */
13
    private $number;
14
15
    /**
16
     * @param float $number
17
     */
18 9
    public function __construct($number = null)
19
    {
20 9
        $this->number = $number;
21 9
    }
22
23
    /**
24
     * @return float
25
     */
26 3
    public function getNumber()
27
    {
28 3
        return $this->number;
29
    }
30
31
    /**
32
     * @param float $number
33
     */
34 3
    public function setNumber($number)
35
    {
36 3
        $this->number = (float) $number;
37 3
    }
38
39
    /**
40
     * {@inheritdoc}
41
     */
42 6
    public function shouldBeApplied()
43
    {
44 6
        return $this->number !== null
45 6
            && is_numeric($this->number);
46
    }
47
}
48