Passed
Push — master ( 87284d...4b5c0b )
by Damien
02:08
created

Element::getDistance()   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
3
namespace DH\NavigationBundle\Model\DistanceMatrix;
4
5
use DH\NavigationBundle\Model\Distance;
6
use DH\NavigationBundle\Model\Duration;
7
8
class Element
9
{
10
    public const STATUS_OK = 'OK';
11
    public const STATUS_NOT_FOUND = 'NOT_FOUND';
12
    public const STATUS_ZERO_RESULTS = 'ZERO_RESULTS';
13
14
    public const STATUS = [
15
        self::STATUS_OK,
16
        self::STATUS_NOT_FOUND,
17
        self::STATUS_ZERO_RESULTS,
18
    ];
19
20
    private $status;
21
22
    private $duration;
23
24
    private $distance;
25
26
    /**
27
     * Element constructor.
28
     *
29
     * @param $status
30
     * @param Duration $duration
31
     * @param Distance $distance
32
     *
33
     * @throws \Exception
34
     */
35
    public function __construct($status, Duration $duration, Distance $distance)
36
    {
37
        if (!\in_array($status, self::STATUS, true)) {
38
            throw new \Exception(sprintf('Unknown status code: %s', $status));
39
        }
40
41
        $this->status = $status;
42
        $this->duration = $duration;
43
        $this->distance = $distance;
44
    }
45
46
    /**
47
     * @return string
48
     */
49
    public function getStatus(): string
50
    {
51
        return $this->status;
52
    }
53
54
    /**
55
     * @return Duration
56
     */
57
    public function getDuration(): Duration
58
    {
59
        return $this->duration;
60
    }
61
62
    /**
63
     * @return Distance
64
     */
65
    public function getDistance(): Distance
66
    {
67
        return $this->distance;
68
    }
69
}
70