Skip to content

Commit 9cc8dcd

Browse files
committed
fix code style according to latest ruleset
1 parent 734c5e5 commit 9cc8dcd

File tree

8 files changed

+58
-46
lines changed

8 files changed

+58
-46
lines changed

src/Data.php

Lines changed: 7 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/Data/Feature.php

Lines changed: 9 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/Data/FeatureCollection.php

Lines changed: 4 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/Data/Geometry.php

Lines changed: 6 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/Data/Geometry/Type.php

Lines changed: 2 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/Decoder.php

Lines changed: 16 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22

33
namespace MBolli\PhpGeobuf;
44

5-
use Exception;
65
use Google\Protobuf\Internal\RepeatedField;
76
use MBolli\PhpGeobuf\Data\Feature;
87
use MBolli\PhpGeobuf\Data\FeatureCollection;
@@ -11,7 +10,7 @@
1110

1211
final class Decoder {
1312
private const GEOMETRY_TYPES = ['Point', 'MultiPoint', 'LineString', 'MultiLineString',
14-
'Polygon', 'MultiPolygon', 'GeometryCollection', ];
13+
'Polygon', 'MultiPolygon', 'GeometryCollection', ];
1514

1615
/** @var Data */
1716
private static $data;
@@ -70,7 +69,7 @@ public static function decodeToArray(string $encodedInput): array {
7069

7170
try {
7271
static::$data->mergeFromString($encodedInput);
73-
} catch (Exception $e) {
72+
} catch (\Exception $e) {
7473
throw new GeobufException('Error while decoding Geobuf: ' . $e->getMessage(), 0, $e);
7574
}
7675

@@ -119,7 +118,7 @@ private static function decodeFeature(Feature $feature): array {
119118
private static function decodeProperties(array|RepeatedField $props, array|RepeatedField $values, ?array &$dest = null): array {
120119
$dest ??= [];
121120
$numProps = \count($props);
122-
if (0 === $numProps) {
121+
if ($numProps === 0) {
123122
return $dest;
124123
}
125124

@@ -131,17 +130,17 @@ private static function decodeProperties(array|RepeatedField $props, array|Repea
131130
$val = $values[$props[$i + 1]];
132131
$valueType = $val->getValueType();
133132

134-
if ('string_value' == $valueType) {
133+
if ($valueType === 'string_value') {
135134
$dest[$key] = $val->getStringValue();
136-
} elseif ('double_value' == $valueType) {
135+
} elseif ($valueType === 'double_value') {
137136
$dest[$key] = $val->getDoubleValue();
138-
} elseif ('pos_int_value' == $valueType) {
137+
} elseif ($valueType === 'pos_int_value') {
139138
$dest[$key] = $val->getPosIntValue();
140-
} elseif ('neg_int_value' == $valueType) {
139+
} elseif ($valueType === 'neg_int_value') {
141140
$dest[$key] = -$val->getNegIntValue();
142-
} elseif ('bool_value' == $valueType) {
141+
} elseif ($valueType === 'bool_value') {
143142
$dest[$key] = $val->getBoolValue();
144-
} elseif ('json_value' == $valueType) {
143+
} elseif ($valueType === 'json_value') {
145144
$dest[$key] = json_decode($val->getJsonValue(), true);
146145
}
147146
}
@@ -151,9 +150,9 @@ private static function decodeProperties(array|RepeatedField $props, array|Repea
151150

152151
private static function decodeId(Feature $feature, array &$objJson): void {
153152
$idType = $feature->getIdType();
154-
if ('id' == $idType) {
153+
if ($idType === 'id') {
155154
$objJson['id'] = $feature->getId();
156-
} elseif ('int_id' == $idType) {
155+
} elseif ($idType === 'int_id') {
157156
$objJson['id'] = $feature->getIntId();
158157
}
159158
}
@@ -162,7 +161,7 @@ private static function decodeId(Feature $feature, array &$objJson): void {
162161
* @return array
163162
*/
164163
private static function decodeGeometry(?Geometry $geometry): ?array {
165-
if (null === $geometry) {
164+
if ($geometry === null) {
166165
return null;
167166
}
168167
$gt = static::GEOMETRY_TYPES[$geometry->getType()];
@@ -186,7 +185,7 @@ private static function decodeGeometry(?Geometry $geometry): ?array {
186185
break;
187186
case 'MultiLineString':
188187
case 'Polygon':
189-
$obj['coordinates'] = static::decodeMultiLine($geometry, 'Polygon' === $gt);
188+
$obj['coordinates'] = static::decodeMultiLine($geometry, $gt === 'Polygon');
190189
break;
191190
case 'MultiPolygon':
192191
$obj['coordinates'] = static::decodeMultiPolygon($geometry);
@@ -230,7 +229,7 @@ private static function decodeLine($coords, ?bool $isClosed = false): array {
230229
$p0 = $p;
231230
}
232231

233-
if (true === $isClosed) {
232+
if ($isClosed === true) {
234233
$p = array_map(fn ($j) => $coords[$j], $r);
235234
$obj[] = static::decodePoint($p);
236235
}
@@ -240,7 +239,7 @@ private static function decodeLine($coords, ?bool $isClosed = false): array {
240239

241240
private static function decodeMultiLine(Geometry $geometry, ?bool $isClosed = false): array {
242241
$coords = $geometry->getCoords();
243-
if (0 === \count($geometry->getLengths())) {
242+
if (\count($geometry->getLengths()) === 0) {
244243
return [static::decodeLine($coords, $isClosed)];
245244
}
246245

@@ -258,7 +257,7 @@ private static function decodeMultiLine(Geometry $geometry, ?bool $isClosed = fa
258257
private static function decodeMultiPolygon(Geometry $geometry): array {
259258
$lengths = $geometry->getLengths();
260259
$coords = $geometry->getCoords();
261-
if (0 === \count($lengths)) {
260+
if (\count($lengths) === 0) {
262261
return [[static::decodeLine($coords, true)]];
263262
}
264263

0 commit comments

Comments
 (0)