1 | <?php |
||
2 | |||
3 | namespace BultonFr\NMEA\Frames; |
||
4 | |||
5 | use \DateTime; |
||
6 | use \DateTimeZone; |
||
7 | |||
8 | /** |
||
9 | * Define the parser system for GGA frame type |
||
10 | * |
||
11 | * @package BultonFr\NMEA |
||
12 | * @author Vermeulen Maxime <[email protected]> |
||
13 | * @link http://www.gpsinformation.org/dale/nmea.htm#GGA |
||
14 | */ |
||
15 | class GGA extends \BultonFr\NMEA\Frame |
||
16 | { |
||
17 | /** |
||
18 | * {@inheritdoc} |
||
19 | */ |
||
20 | protected $frameType = 'GGA'; |
||
21 | |||
22 | /** |
||
23 | * Format : --GGA,hhmmss.ss,llll.ll,a,yyyyy.yy,a,x,xx,x.x,x.x,M,x.x,M,x.x,xxxx |
||
24 | * {@inheritdoc} |
||
25 | */ |
||
26 | protected $frameRegex = '/^' |
||
27 | .'([A-Z]{2}[A-Z]{3}),' //Equipment and trame type |
||
28 | .'(\d{6}\.\d{2,3}),' //Time (UTC) |
||
29 | .'([0-9\.]+),' //Latitude |
||
30 | .'(N|S),' //N or S (North or South) |
||
31 | .'([0-9\.]+),' //Longitude |
||
32 | .'(E|W),' //E or W (East or West) |
||
33 | .'(\d{0,1}),' //GPS Quality Indicator |
||
34 | .'(\d{0,2}),' //Number of satellites in view, 00 - 12 |
||
35 | .'([0-9\.]*),' //Horizontal Dilution of position |
||
36 | .'([0-9\.]*),' //Antenna Altitude above/below mean-sea-level (geoid) |
||
37 | .'([A-Z]{0,1}),' //Units of antenna altitude, meters |
||
38 | .'([0-9\.-]*),' //Geoidal separation, the difference between the WGS-84 |
||
39 | //earth ellipsoid and mean-sea-level (geoid), "-" means mean-sea-level below ellipsoid |
||
40 | .'([A-Z]{0,1}),' //Units of geoidal separation, meters |
||
41 | .'([0-9\.]*),' //Age of differential GPS data, time in seconds since last SC104 |
||
42 | //type 1 or 9 update, null field when DGPS is not used |
||
43 | .'(\d{0,4})' //DGPS station ID, 0000-1023 |
||
44 | .'$/m'; |
||
45 | |||
46 | /** |
||
47 | * @var \DateTime $utcTime Time of the line (UTC) |
||
48 | */ |
||
49 | protected $utcTime; |
||
50 | |||
51 | /** |
||
52 | * @var string $latitude Latitude |
||
53 | */ |
||
54 | protected $latitude; |
||
55 | |||
56 | /** |
||
57 | * @var string $latitudeDirection N or S (North or South) |
||
58 | */ |
||
59 | protected $latitudeDirection; |
||
60 | |||
61 | /** |
||
62 | * @var string $longitude Longitude |
||
63 | */ |
||
64 | protected $longitude; |
||
65 | |||
66 | /** |
||
67 | * @var string $longitudeDirection E or W (East or West) |
||
68 | */ |
||
69 | protected $longitudeDirection; |
||
70 | |||
71 | /** |
||
72 | * @var int $gpsQuality GPS Quality Indicator |
||
73 | * * 0 - fix not available, |
||
74 | * * 1 - GPS fix (SPS), |
||
75 | * * 2 - Differential GPS fix (DGPS) |
||
76 | * * 3 - PPS fix |
||
77 | * * 4 - Real Time Kinematic |
||
78 | * * 5 - Float RTK |
||
79 | * * 6 - estimated (dead reckoning) (2.3 feature) |
||
80 | * * 7 - Manual input mode |
||
81 | * * 8 - Simulation mode |
||
82 | */ |
||
83 | protected $gpsQuality; |
||
84 | |||
85 | /** |
||
86 | * @var int $nbSatellites Number of satellites in view, 0 to 12 |
||
87 | */ |
||
88 | protected $nbSatellites; |
||
89 | |||
90 | /** |
||
91 | * @var float $horizontalDilutionPrecision Horizontal Dilution of precision |
||
92 | */ |
||
93 | protected $horizontalDilutionPrecision; |
||
94 | |||
95 | /** |
||
96 | * @var float $altitude Antenna Altitude above/below mean-sea-level (geoid) |
||
97 | */ |
||
98 | protected $altitude; |
||
99 | |||
100 | /** |
||
101 | * @var string $altitudeUnit Units of antenna altitude, meters |
||
102 | */ |
||
103 | protected $altitudeUnit; |
||
104 | |||
105 | /** |
||
106 | * @var float $geoidalSeparation Geoidal separation, the difference |
||
107 | * between the WGS-84 earth ellipsoid and mean-sea-level (geoid); |
||
108 | * "-" means mean-sea-level below ellipsoid |
||
109 | */ |
||
110 | protected $geoidalSeparation; |
||
111 | |||
112 | /** |
||
113 | * @var string $geoidalSeparationUnit Units of geoidal separation, meters |
||
114 | */ |
||
115 | protected $geoidalSeparationUnit; |
||
116 | |||
117 | /** |
||
118 | * @var float $ageGpsData Age of differential GPS data, time in seconds |
||
119 | * since last SC104. Type 1 or 9 update, null field when DGPS is not used |
||
120 | */ |
||
121 | protected $ageGpsData; |
||
122 | |||
123 | /** |
||
124 | * @var int $differentialRefStationId Differential reference station ID, |
||
125 | * 0 to 1023 |
||
126 | */ |
||
127 | protected $differentialRefStationId; |
||
128 | |||
129 | /** |
||
130 | * Getter to property utcTime |
||
131 | * |
||
132 | * @return \DateTime |
||
133 | */ |
||
134 | public function getUtcTime() |
||
135 | { |
||
136 | 1 | return $this->utcTime; |
|
137 | } |
||
138 | |||
139 | /** |
||
140 | * Getter to property latitude |
||
141 | * |
||
142 | * @return string |
||
143 | */ |
||
144 | public function getLatitude() |
||
145 | { |
||
146 | 1 | return $this->latitude; |
|
147 | } |
||
148 | |||
149 | /** |
||
150 | * Getter to property latitudeDirection |
||
151 | * |
||
152 | * @return string |
||
153 | */ |
||
154 | public function getLatitudeDirection() |
||
155 | { |
||
156 | 1 | return $this->latitudeDirection; |
|
157 | } |
||
158 | |||
159 | /** |
||
160 | * Getter to property longitude |
||
161 | * |
||
162 | * @return string |
||
163 | */ |
||
164 | public function getLongitude() |
||
165 | { |
||
166 | 1 | return $this->longitude; |
|
167 | } |
||
168 | |||
169 | /** |
||
170 | * Getter to property longitudeDirection |
||
171 | * |
||
172 | * @return string |
||
173 | */ |
||
174 | public function getLongitudeDirection() |
||
175 | { |
||
176 | 1 | return $this->longitudeDirection; |
|
177 | } |
||
178 | |||
179 | /** |
||
180 | * Getter to property gpsQuality |
||
181 | * |
||
182 | * @return int |
||
183 | */ |
||
184 | public function getGpsQuality() |
||
185 | { |
||
186 | 1 | return $this->gpsQuality; |
|
187 | } |
||
188 | |||
189 | /** |
||
190 | * Getter to property nbSatellites |
||
191 | * |
||
192 | * @return int |
||
193 | */ |
||
194 | public function getNbSatellites() |
||
195 | { |
||
196 | 1 | return $this->nbSatellites; |
|
197 | } |
||
198 | |||
199 | /** |
||
200 | * Getter to property horizontalDilutionPrecision |
||
201 | * |
||
202 | * @return float |
||
203 | */ |
||
204 | public function getHorizontalDilutionPrecision() |
||
205 | { |
||
206 | 1 | return $this->horizontalDilutionPrecision; |
|
207 | } |
||
208 | |||
209 | /** |
||
210 | * Getter to property altitude |
||
211 | * |
||
212 | * @return float |
||
213 | */ |
||
214 | public function getAltitude() |
||
215 | { |
||
216 | 1 | return $this->altitude; |
|
217 | } |
||
218 | |||
219 | /** |
||
220 | * Getter to property altitudeUnit |
||
221 | * |
||
222 | * @return string |
||
223 | */ |
||
224 | public function getAltitudeUnit() |
||
225 | { |
||
226 | 1 | return $this->altitudeUnit; |
|
227 | } |
||
228 | |||
229 | /** |
||
230 | * Getter to property geoidalSeparation |
||
231 | * |
||
232 | * @return float |
||
233 | */ |
||
234 | public function getGeoidalSeparation() |
||
235 | { |
||
236 | 1 | return $this->geoidalSeparation; |
|
237 | } |
||
238 | |||
239 | /** |
||
240 | * Getter to property geoidalSeparationUnit |
||
241 | * |
||
242 | * @return string |
||
243 | */ |
||
244 | public function getGeoidalSeparationUnit() |
||
245 | { |
||
246 | 1 | return $this->geoidalSeparationUnit; |
|
247 | } |
||
248 | |||
249 | /** |
||
250 | * Getter to property ageGpsData |
||
251 | * |
||
252 | * @return float |
||
253 | */ |
||
254 | public function getAgeGpsData() |
||
255 | { |
||
256 | 1 | return $this->ageGpsData; |
|
257 | } |
||
258 | |||
259 | /** |
||
260 | * Getter to property differentialRefStationId |
||
261 | * |
||
262 | * @return int |
||
263 | */ |
||
264 | public function getDifferentialRefStationId() |
||
265 | { |
||
266 | 1 | return $this->differentialRefStationId; |
|
267 | } |
||
268 | |||
269 | /** |
||
270 | * {@inheritdoc} |
||
271 | */ |
||
272 | protected function decodeFrame($msgParts) |
||
273 | { |
||
274 | 1 | $this->utcTime = DateTime::createFromFormat( |
|
0 ignored issues
–
show
|
|||
275 | 1 | 'His.u', |
|
276 | 1 | $msgParts[2], |
|
277 | 1 | new DateTimeZone('UTC') |
|
278 | ); |
||
279 | |||
280 | 1 | $this->latitude = (string) $msgParts[3]; |
|
281 | 1 | $this->latitudeDirection = (string) $msgParts[4]; |
|
282 | 1 | $this->longitude = (string) $msgParts[5]; |
|
283 | 1 | $this->longitudeDirection = (string) $msgParts[6]; |
|
284 | |||
285 | 1 | $this->gpsQuality = (int) $msgParts[7]; |
|
286 | 1 | $this->nbSatellites = (int) $msgParts[8]; |
|
287 | 1 | $this->horizontalDilutionPrecision = (float) $msgParts[9]; |
|
288 | |||
289 | 1 | $this->altitude = (float) $msgParts[10]; |
|
290 | 1 | $this->altitudeUnit = (string) $msgParts[11]; |
|
291 | |||
292 | 1 | $this->geoidalSeparation = (float) $msgParts[12]; |
|
293 | 1 | $this->geoidalSeparationUnit = (string) $msgParts[13]; |
|
294 | |||
295 | 1 | $this->ageGpsData = (float) $msgParts[14]; |
|
296 | 1 | $this->differentialRefStationId = (int) $msgParts[15]; |
|
297 | 1 | } |
|
298 | } |
||
299 |
Our type inference engine has found a suspicous assignment of a value to a property. This check raises an issue when a value that can be of a mixed type is assigned to a property that is type hinted more strictly.
For example, imagine you have a variable
$accountId
that can either hold an Id object or false (if there is no account id yet). Your code now assigns that value to theid
property of an instance of theAccount
class. This class holds a proper account, so the id value must no longer be false.Either this assignment is in error or a type check should be added for that assignment.