Completed
Pull Request — master (#4)
by ARCANEDEV
01:52
created

Leg   A

Complexity

Total Complexity 10

Size/Duplication

Total Lines 179
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 5

Importance

Changes 0
Metric Value
wmc 10
lcom 0
cbo 5
dl 0
loc 179
rs 10
c 0
b 0
f 0

10 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 16 1
A startAddress() 0 4 1
A startLocation() 0 4 1
A endAddress() 0 4 1
A endLocation() 0 4 1
A distance() 0 4 1
A duration() 0 4 1
A steps() 0 4 1
A trafficSpeedEntry() 0 4 1
A viaWaypoint() 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     Leg
10
 *
11
 * @package  Arcanedev\GeoLocation\Google\Directions\Entities
12
 * @author   ARCANEDEV <[email protected]>
13
 */
14
class Leg
15
{
16
    /* -----------------------------------------------------------------
17
     |  Properties
18
     | -----------------------------------------------------------------
19
     */
20
21
    /**
22
     * The start address.
23
     *
24
     * @var string
25
     */
26
    protected $startAddress;
27
28
    /**
29
     * The start location.
30
     *
31
     * @var \Arcanedev\GeoLocation\Contracts\Entities\Position
32
     */
33
    protected $startLocation;
34
35
    /**
36
     * The end address
37
     *
38
     * @var string
39
     */
40
    protected $endAddress;
41
42
    /**
43
     * The end location.
44
     *
45
     * @var \Arcanedev\GeoLocation\Contracts\Entities\Position
46
     */
47
    protected $endLocation;
48
49
    /**
50
     * The distance (text + value).
51
     *
52
     * @var array
53
     */
54
    protected $distance;
55
56
    /**
57
     * The duration (text + value).
58
     *
59
     * @var array
60
     */
61
    protected $duration;
62
63
    /**
64
     * The steps collection.
65
     *
66
     * @var \Arcanedev\GeoLocation\Google\Directions\Entities\StepCollection
67
     */
68
    protected $steps;
69
70
    /**
71
     * The traffic speed entry.
72
     *
73
     * @var array
74
     */
75
    protected $trafficSpeedEntry;
76
77
    /**
78
     * The via waypoint.
79
     *
80
     * @var array
81
     */
82
    protected $viaWaypoint;
83
84
    /* -----------------------------------------------------------------
85
     |  Main Methods
86
     | -----------------------------------------------------------------
87
     */
88
89
    /**
90
     * Leg constructor.
91
     *
92
     * @param  array  $data
93
     */
94
    public function __construct(array $data)
95
    {
96
        $this->startAddress  = Arr::get($data, 'start_address', '');
97
        $this->startLocation = Position::createFromArray(Arr::get($data, 'start_location', ['lat' => 0, 'lng' => 0]));
98
99
        $this->endAddress    = Arr::get($data, 'end_address', '');
100
        $this->endLocation   = Position::createFromArray(Arr::get($data, 'end_location', ['lat' => 0, 'lng' => 0]));
101
102
        $this->distance      = Distance::makeFromArray(Arr::get($data, 'distance', ['text' => '', 'value' => 0]));
0 ignored issues
show
Documentation Bug introduced by
It seems like \Arcanedev\GeoLocation\E... => '', 'value' => 0))) of type object<Arcanedev\GeoLocation\Entities\Distance> is incompatible with the declared type array of property $distance.

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...
103
        $this->duration      = Duration::makeFromArray(Arr::get($data, 'duration', ['text' => '', 'value' => 0]));
0 ignored issues
show
Documentation Bug introduced by
It seems like \Arcanedev\GeoLocation\E... => '', 'value' => 0))) of type object<Arcanedev\GeoLocation\Entities\Duration> is incompatible with the declared type array of property $duration.

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...
104
105
        $this->steps         = StepCollection::load(Arr::get($data, 'steps', []));
106
107
        $this->trafficSpeedEntry = Arr::get($data, 'traffic_speed_entry', []);
0 ignored issues
show
Documentation Bug introduced by
It seems like \Illuminate\Support\Arr:..._speed_entry', array()) of type * is incompatible with the declared type array of property $trafficSpeedEntry.

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...
108
        $this->viaWaypoint       = Arr::get($data, 'via_waypoint', []);
0 ignored issues
show
Documentation Bug introduced by
It seems like \Illuminate\Support\Arr:...via_waypoint', array()) of type * is incompatible with the declared type array of property $viaWaypoint.

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...
109
    }
110
111
    /* -----------------------------------------------------------------
112
     |  Getters & Setters
113
     | -----------------------------------------------------------------
114
     */
115
    /**
116
     * @return string
117
     */
118
    public function startAddress()
119
    {
120
        return $this->startAddress;
121
    }
122
123
    /**
124
     * @return \Arcanedev\GeoLocation\Contracts\Entities\Position
125
     */
126
    public function startLocation()
127
    {
128
        return $this->startLocation;
129
    }
130
131
    /**
132
     * @return string
133
     */
134
    public function endAddress()
135
    {
136
        return $this->endAddress;
137
    }
138
139
    /**
140
     * @return \Arcanedev\GeoLocation\Contracts\Entities\Position
141
     */
142
    public function endLocation()
143
    {
144
        return $this->endLocation;
145
    }
146
147
    /**
148
     * @return array
149
     */
150
    public function distance()
151
    {
152
        return $this->distance;
153
    }
154
155
    /**
156
     * @return array
157
     */
158
    public function duration()
159
    {
160
        return $this->duration;
161
    }
162
163
    /**
164
     * Get the step collection.
165
     *
166
     * @return \Arcanedev\GeoLocation\Google\Directions\Entities\StepCollection
167
     */
168
    public function steps()
169
    {
170
        return $this->steps;
171
    }
172
173
    /**
174
     * Get the traffic speed entry.
175
     *
176
     * @return array
177
     */
178
    public function trafficSpeedEntry()
179
    {
180
        return $this->trafficSpeedEntry;
181
    }
182
183
    /**
184
     * Get the via waypoint.
185
     *
186
     * @return array
187
     */
188
    public function viaWaypoint()
189
    {
190
        return $this->viaWaypoint;
191
    }
192
}
193