Step::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 4
nc 1
nop 1
dl 0
loc 6
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace DH\NavigationBundle\Model\Routing;
4
5
use DH\NavigationBundle\Model\Distance;
6
use DH\NavigationBundle\Model\Duration;
7
8
class Step
9
{
10
    /**
11
     * @var array
12
     */
13
    private $position;
14
15
    /**
16
     * @var Distance
17
     */
18
    private $distance;
19
20
    /**
21
     * @var Duration
22
     */
23
    private $duration;
24
25
    /**
26
     * @var string
27
     */
28
    private $instruction;
29
30
    public function __construct(array $data)
31
    {
32
        $this->position = $data['position'] ?? [];
33
        $this->instruction = $data['instruction'] ?? '';
34
        $this->duration = new Duration((int) ($data['duration'] ?? 0));
35
        $this->distance = new Distance((int) ($data['distance'] ?? 0));
36
    }
37
38
    /**
39
     * Get the value of position.
40
     */
41
    public function getPosition(): array
42
    {
43
        return $this->position;
44
    }
45
46
    /**
47
     * Get the value of distance.
48
     */
49
    public function getDistance(): Distance
50
    {
51
        return $this->distance;
52
    }
53
54
    /**
55
     * Get the value of duration.
56
     */
57
    public function getDuration(): Duration
58
    {
59
        return $this->duration;
60
    }
61
62
    /**
63
     * Get the value of instruction.
64
     */
65
    public function getInstruction(): string
66
    {
67
        return $this->instruction;
68
    }
69
}
70