Completed
Pull Request — master (#4)
by ARCANEDEV
06:24
created

Step   A

Complexity

Total Complexity 8

Size/Duplication

Total Lines 151
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 4

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 8
lcom 0
cbo 4
dl 0
loc 151
ccs 23
cts 23
cp 1
rs 10
c 0
b 0
f 0

8 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 10 1
A start() 0 4 1
A end() 0 4 1
A distance() 0 4 1
A duration() 0 4 1
A mode() 0 4 1
A instructions() 0 4 1
A polyline() 0 4 1
1
<?php namespace Arcanedev\GeoLocation\Google\Directions\Entities;
2
3
use Arcanedev\GeoLocation\Entities\Distance;
4
use Arcanedev\GeoLocation\Entities\Duration;
5
use Arcanedev\GeoLocation\Entities\Position;
6
use Illuminate\Support\Arr;
7
8
/**
9
 * Class     Step
10
 *
11
 * @package  Arcanedev\GeoLocation\Google\Directions\Entities
12
 * @author   ARCANEDEV <[email protected]>
13
 */
14
class Step
15
{
16
    /* -----------------------------------------------------------------
17
     |  Properties
18
     | -----------------------------------------------------------------
19
     */
20
21
    /**
22
     * The start location.
23
     *
24
     * @var \Arcanedev\GeoLocation\Contracts\Entities\Position
25
     */
26
    protected $start;
27
28
    /**
29
     * The end location.
30
     *
31
     * @var \Arcanedev\GeoLocation\Contracts\Entities\Position
32
     */
33
    protected $end;
34
35
    /**
36
     * The distance.
37
     *
38
     * @var \Arcanedev\GeoLocation\Entities\Distance
39
     */
40
    protected $distance;
41
42
    /**
43
     * The duration.
44
     *
45
     * @var \Arcanedev\GeoLocation\Entities\Duration
46
     */
47
    protected $duration;
48
49
    /**
50
     * The travel mode.
51
     *
52
     * @var string
53
     */
54
    protected $mode;
55
56
    /**
57
     * The instructions (HTML format).
58
     *
59
     * @var string
60
     */
61
    protected $instructions;
62
63
    /**
64
     * The polyline.
65
     *
66
     * @var array
67
     */
68
    protected $polyline;
69
70
    /* -----------------------------------------------------------------
71
     |  Constructor
72
     | -----------------------------------------------------------------
73
     */
74
75
    /**
76
     * Step constructor.
77
     *
78
     * @param  array  $data
79
     */
80 3
    public function __construct(array $data)
81
    {
82 3
        $this->start        = Position::createFromArray(Arr::get($data, 'start_location', ['lat' => 0, 'lng' => 0]));
83 3
        $this->end          = Position::createFromArray(Arr::get($data, 'end_location', ['lat' => 0, 'lng' => 0]));
84 3
        $this->distance     = Distance::makeFromArray(Arr::get($data, 'distance', ['text' => '', 'value' => 0]));
85 3
        $this->duration     = Duration::makeFromArray(Arr::get($data, 'duration', ['text' => '', 'value' => 0]));
86 3
        $this->instructions = Arr::get($data, 'html_instructions');
87 3
        $this->polyline     = Arr::get($data, 'polyline', []);
0 ignored issues
show
Documentation Bug introduced by
It seems like \Illuminate\Support\Arr:...a, 'polyline', array()) of type * is incompatible with the declared type array of property $polyline.

Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..

Loading history...
88 3
        $this->mode         = Arr::get($data, 'travel_mode');
89 3
    }
90
91
    /* -----------------------------------------------------------------
92
     |  Getters & Setters
93
     | -----------------------------------------------------------------
94
     */
95
96
    /**
97
     * Get the start location.
98
     *
99
     * @return \Arcanedev\GeoLocation\Contracts\Entities\Position
100
     */
101 3
    public function start()
102
    {
103 3
        return $this->start;
104
    }
105
106
    /**
107
     * Get the end location.
108
     *
109
     * @return \Arcanedev\GeoLocation\Contracts\Entities\Position
110
     */
111 3
    public function end()
112
    {
113 3
        return $this->end;
114
    }
115
116
    /**
117
     * Get the distance.
118
     *
119
     * @return \Arcanedev\GeoLocation\Entities\Distance
120
     */
121 3
    public function distance()
122
    {
123 3
        return $this->distance;
124
    }
125
126
    /**
127
     * Get the duration.
128
     *
129
     * @return \Arcanedev\GeoLocation\Entities\Duration
130
     */
131 3
    public function duration()
132
    {
133 3
        return $this->duration;
134
    }
135
136
    /**
137
     * Get the traveling mode.
138
     *
139
     * @return string
140
     */
141 3
    public function mode()
142
    {
143 3
        return $this->mode;
144
    }
145
146
    /**
147
     * Get the instructions (HTML format)
148
     * @return string
149
     */
150 3
    public function instructions()
151
    {
152 3
        return $this->instructions;
153
    }
154
155
    /**
156
     * Get the polyline.
157
     *
158
     * @return array
159
     */
160 3
    public function polyline()
161
    {
162 3
        return $this->polyline;
163
    }
164
}
165