CoordinatesCriteria::setLatitude()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 4
ccs 3
cts 3
cp 1
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 1
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 CoordinatesCriteria implements CriteriaInterface
10
{
11
    /**
12
     * @var float
13
     */
14
    private $latitude;
15
16
    /**
17
     * @var float
18
     */
19
    private $longitude;
20
21
    /**
22
     * @param float $latitude
23
     * @param float $longitude
24
     */
25 8
    public function __construct(float $latitude = null, float $longitude = null)
26
    {
27 8
        $this->latitude = $latitude;
28 8
        $this->longitude = $longitude;
29 8
    }
30
31
    /**
32
     * @return float|null
33
     */
34 2
    public function getLatitude()
35
    {
36 2
        return $this->latitude;
37
    }
38
39
    /**
40
     * @param float $latitude
41
     */
42 2
    public function setLatitude(float $latitude = null)
43
    {
44 2
        $this->latitude = $latitude;
45 2
    }
46
47
    /**
48
     * @return float|null
49
     */
50 2
    public function getLongitude()
51
    {
52 2
        return $this->longitude;
53
    }
54
55
    /**
56
     * @param float $longitude
57
     */
58 2
    public function setLongitude(float $longitude = null)
59
    {
60 2
        $this->longitude = $longitude;
61 2
    }
62
63
    /**
64
     * {@inheritdoc}
65
     */
66 5
    public function shouldBeApplied(): bool
67
    {
68 5
        return $this->latitude !== null
69 5
            && $this->longitude !== null;
70
    }
71
}
72