Skip to content

Commit 84ed34a

Browse files
grimzyChrissi2812
authored andcommitted
Style CI fix 🎭
(cherry picked from commit 8add88a)
1 parent 4ca6a89 commit 84ed34a

18 files changed

+98
-74
lines changed

src/Exceptions/InvalidGeoJsonException.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,4 @@
44

55
class InvalidGeoJsonException extends \RuntimeException
66
{
7-
}
7+
}

src/Types/Geometry.php

+6-4
Original file line numberDiff line numberDiff line change
@@ -72,20 +72,22 @@ public static function fromWKT($wkt)
7272
return static::fromString($wktArgument);
7373
}
7474

75-
public static function fromJson($geoJson) {
76-
if(is_string($geoJson)) {
75+
public static function fromJson($geoJson)
76+
{
77+
if (is_string($geoJson)) {
7778
$geoJson = GeoJson::jsonUnserialize(json_decode($geoJson));
7879
}
7980

80-
if($geoJson->getType() === 'FeatureCollection') {
81+
if ($geoJson->getType() === 'FeatureCollection') {
8182
return GeometryCollection::fromJson($geoJson);
8283
}
8384

84-
if($geoJson->getType() === 'Feature') {
85+
if ($geoJson->getType() === 'Feature') {
8586
$geoJson = $geoJson->getGeometry();
8687
}
8788

8889
$type = '\Grimzy\LaravelMysqlSpatial\Types\\'.$geoJson->getType();
90+
8991
return $type::fromJson($geoJson);
9092
}
9193

src/Types/GeometryCollection.php

+5-5
Original file line numberDiff line numberDiff line change
@@ -110,22 +110,22 @@ public function count()
110110
return count($this->items);
111111
}
112112

113-
public static function fromJson ($geoJson)
113+
public static function fromJson($geoJson)
114114
{
115-
if(is_string($geoJson)) {
115+
if (is_string($geoJson)) {
116116
$geoJson = GeoJson::jsonUnserialize(json_decode($geoJson));
117117
}
118118

119-
if(!is_a($geoJson, FeatureCollection::class)) {
120-
throw new InvalidGeoJsonException('Expected ' . FeatureCollection::class . ', got ' . get_class($geoJson));
119+
if (!is_a($geoJson, FeatureCollection::class)) {
120+
throw new InvalidGeoJsonException('Expected '.FeatureCollection::class.', got '.get_class($geoJson));
121121
}
122122

123123
$set = [];
124124
foreach ($geoJson->getFeatures() as $feature) {
125125
$set[] = parent::fromJson($feature);
126126
}
127127

128-
return new GeometryCollection($set);
128+
return new self($set);
129129
}
130130

131131
/**

src/Types/LineString.php

+6-6
Original file line numberDiff line numberDiff line change
@@ -35,22 +35,22 @@ public function __toString()
3535
return $this->toPairList();
3636
}
3737

38-
public static function fromJson ($geoJson)
38+
public static function fromJson($geoJson)
3939
{
40-
if(is_string($geoJson)) {
40+
if (is_string($geoJson)) {
4141
$geoJson = GeoJson::jsonUnserialize(json_decode($geoJson));
4242
}
4343

44-
if(!is_a($geoJson, GeoJsonLineString::class)) {
45-
throw new InvalidGeoJsonException('Expected ' . GeoJsonLineString::class . ', got ' . get_class($geoJson));
44+
if (!is_a($geoJson, GeoJsonLineString::class)) {
45+
throw new InvalidGeoJsonException('Expected '.GeoJsonLineString::class.', got '.get_class($geoJson));
4646
}
4747

4848
$set = [];
49-
foreach($geoJson->getCoordinates() as $coordinate) {
49+
foreach ($geoJson->getCoordinates() as $coordinate) {
5050
$set[] = new Point($coordinate[1], $coordinate[0]);
5151
}
5252

53-
return new LineString($set);
53+
return new self($set);
5454
}
5555

5656
/**

src/Types/MultiLineString.php

+7-7
Original file line numberDiff line numberDiff line change
@@ -65,26 +65,26 @@ public function offsetSet($offset, $value)
6565
parent::offsetSet($offset, $value);
6666
}
6767

68-
public static function fromJson ($geoJson)
68+
public static function fromJson($geoJson)
6969
{
70-
if(is_string($geoJson)) {
70+
if (is_string($geoJson)) {
7171
$geoJson = GeoJson::jsonUnserialize(json_decode($geoJson));
7272
}
7373

74-
if(!is_a($geoJson, GeoJsonMultiLineString::class)) {
75-
throw new InvalidGeoJsonException('Expected ' . GeoJsonMultiLineString::class . ', got ' . get_class($geoJson));
74+
if (!is_a($geoJson, GeoJsonMultiLineString::class)) {
75+
throw new InvalidGeoJsonException('Expected '.GeoJsonMultiLineString::class.', got '.get_class($geoJson));
7676
}
7777

7878
$set = [];
79-
foreach($geoJson->getCoordinates() as $coordinates) {
79+
foreach ($geoJson->getCoordinates() as $coordinates) {
8080
$points = [];
81-
foreach($coordinates as $coordinate) {
81+
foreach ($coordinates as $coordinate) {
8282
$points[] = new Point($coordinate[1], $coordinate[0]);
8383
}
8484
$set[] = new LineString($points);
8585
}
8686

87-
return new MultiLineString($set);
87+
return new self($set);
8888
}
8989

9090
/**

src/Types/MultiPoint.php

+6-6
Original file line numberDiff line numberDiff line change
@@ -39,22 +39,22 @@ public function __toString()
3939
}, $this->items));
4040
}
4141

42-
public static function fromJson ($geoJson)
42+
public static function fromJson($geoJson)
4343
{
44-
if(is_string($geoJson)) {
44+
if (is_string($geoJson)) {
4545
$geoJson = GeoJson::jsonUnserialize(json_decode($geoJson));
4646
}
4747

48-
if(!is_a($geoJson, GeoJsonMultiPoint::class)) {
49-
throw new InvalidGeoJsonException('Expected ' . GeoJsonMultiPoint::class . ', got ' . get_class($geoJson));
48+
if (!is_a($geoJson, GeoJsonMultiPoint::class)) {
49+
throw new InvalidGeoJsonException('Expected '.GeoJsonMultiPoint::class.', got '.get_class($geoJson));
5050
}
5151

5252
$set = [];
53-
foreach($geoJson->getCoordinates() as $coordinate) {
53+
foreach ($geoJson->getCoordinates() as $coordinate) {
5454
$set[] = new Point($coordinate[1], $coordinate[0]);
5555
}
5656

57-
return new MultiPoint($set);
57+
return new self($set);
5858
}
5959

6060
/**

src/Types/MultiPolygon.php

+8-8
Original file line numberDiff line numberDiff line change
@@ -100,30 +100,30 @@ public function offsetSet($offset, $value)
100100
parent::offsetSet($offset, $value);
101101
}
102102

103-
public static function fromJson ($geoJson)
103+
public static function fromJson($geoJson)
104104
{
105-
if(is_string($geoJson)) {
105+
if (is_string($geoJson)) {
106106
$geoJson = GeoJson::jsonUnserialize(json_decode($geoJson));
107107
}
108108

109-
if(!is_a($geoJson, GeoJsonMultiPolygon::class)) {
110-
throw new InvalidGeoJsonException('Expected ' . GeoJsonMultiPolygon::class . ', got ' . get_class($geoJson));
109+
if (!is_a($geoJson, GeoJsonMultiPolygon::class)) {
110+
throw new InvalidGeoJsonException('Expected '.GeoJsonMultiPolygon::class.', got '.get_class($geoJson));
111111
}
112112

113113
$set = [];
114-
foreach($geoJson->getCoordinates() as $polygonCoordinates) {
114+
foreach ($geoJson->getCoordinates() as $polygonCoordinates) {
115115
$lineStrings = [];
116-
foreach($polygonCoordinates as $lineStringCoordinates) {
116+
foreach ($polygonCoordinates as $lineStringCoordinates) {
117117
$points = [];
118-
foreach($lineStringCoordinates as $lineStringCoordinate) {
118+
foreach ($lineStringCoordinates as $lineStringCoordinate) {
119119
$points[] = new Point($lineStringCoordinate[1], $lineStringCoordinate[0]);
120120
}
121121
$lineStrings[] = new LineString($points);
122122
}
123123
$set[] = new Polygon($lineStrings);
124124
}
125125

126-
return new MultiPolygon($set);
126+
return new self($set);
127127
}
128128

129129
/**

src/Types/Point.php

+7-5
Original file line numberDiff line numberDiff line change
@@ -67,20 +67,22 @@ public function __toString()
6767

6868
/**
6969
* @param $geoJson \GeoJson\Feature\Feature|string
70+
*
7071
* @return \Grimzy\LaravelMysqlSpatial\Types\Point
7172
*/
72-
public static function fromJson ($geoJson)
73+
public static function fromJson($geoJson)
7374
{
74-
if(is_string($geoJson)) {
75+
if (is_string($geoJson)) {
7576
$geoJson = GeoJson::jsonUnserialize(json_decode($geoJson));
7677
}
7778

78-
if(!is_a($geoJson, GeoJsonPoint::class)) {
79-
throw new InvalidGeoJsonException('Expected ' . GeoJsonPoint::class . ', got ' . get_class($geoJson));
79+
if (!is_a($geoJson, GeoJsonPoint::class)) {
80+
throw new InvalidGeoJsonException('Expected '.GeoJsonPoint::class.', got '.get_class($geoJson));
8081
}
8182

8283
$coordinates = $geoJson->getCoordinates();
83-
return new Point($coordinates[1], $coordinates[0]);
84+
85+
return new self($coordinates[1], $coordinates[0]);
8486
}
8587

8688
/**

src/Types/Polygon.php

+7-7
Original file line numberDiff line numberDiff line change
@@ -13,26 +13,26 @@ public function toWKT()
1313
return sprintf('POLYGON(%s)', (string) $this);
1414
}
1515

16-
public static function fromJson ($geoJson)
16+
public static function fromJson($geoJson)
1717
{
18-
if(is_string($geoJson)) {
18+
if (is_string($geoJson)) {
1919
$geoJson = GeoJson::jsonUnserialize(json_decode($geoJson));
2020
}
2121

22-
if(!is_a($geoJson, GeoJsonPolygon::class)) {
23-
throw new InvalidGeoJsonException('Expected ' . GeoJsonPolygon::class . ', got ' . get_class($geoJson));
22+
if (!is_a($geoJson, GeoJsonPolygon::class)) {
23+
throw new InvalidGeoJsonException('Expected '.GeoJsonPolygon::class.', got '.get_class($geoJson));
2424
}
2525

2626
$set = [];
27-
foreach($geoJson->getCoordinates() as $coordinates) {
27+
foreach ($geoJson->getCoordinates() as $coordinates) {
2828
$points = [];
29-
foreach($coordinates as $coordinate) {
29+
foreach ($coordinates as $coordinate) {
3030
$points[] = new Point($coordinate[1], $coordinate[0]);
3131
}
3232
$set[] = new LineString($points);
3333
}
3434

35-
return new Polygon($set);
35+
return new self($set);
3636
}
3737

3838
/**

tests/Unit/Eloquent/SpatialTraitTest.php

+6-3
Original file line numberDiff line numberDiff line change
@@ -192,14 +192,16 @@ public function testInsertUpdateGeometryCollectionHasCorrectSql()
192192
$this->assertContains("GeomFromText('GEOMETRYCOLLECTION(POINT(2 1),LINESTRING(3 2,3 3))')", $this->queries[1]);
193193
}
194194

195-
public function testSettingRawAttributes() {
195+
public function testSettingRawAttributes()
196+
{
196197
$attributes['point'] = '0101000000000000000000f03f0000000000000040';
197198

198199
$this->model->setRawAttributes($attributes);
199200
$this->assertInstanceOf(Point::class, ($this->model->point));
200201
}
201202

202-
public function testSpatialFieldsNotDefinedException() {
203+
public function testSpatialFieldsNotDefinedException()
204+
{
203205
$model = new TestNoSpatialModel();
204206
$this->setExpectedException(SpatialFieldsNotDefinedException::class);
205207
$model->getSpatialFields();
@@ -403,7 +405,8 @@ public function testmodels()
403405
}
404406
}
405407

406-
class TestNoSpatialModel extends Model {
408+
class TestNoSpatialModel extends Model
409+
{
407410
use \Grimzy\LaravelMysqlSpatial\Eloquent\SpatialTrait;
408411
}
409412

tests/Unit/Types/GeometryCollectionTest.php

+4-2
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,8 @@ public function testArrayAccess()
8989
$geometryCollection[] = 1;
9090
}
9191

92-
public function testFromJson() {
92+
public function testFromJson()
93+
{
9394
$geometryCollection = GeometryCollection::fromJson('{"type":"FeatureCollection","features":[{"type":"Feature","properties":{},"geometry":{"type":"Point","coordinates":[1,2]}},{"type":"Feature","properties":{},"geometry":{"type":"Point","coordinates":[3,4]}}]}');
9495
$this->assertInstanceOf(GeometryCollection::class, $geometryCollection);
9596
$geometryCollectionPoints = $geometryCollection->getGeometries();
@@ -98,7 +99,8 @@ public function testFromJson() {
9899
$this->assertEquals(new Point(4, 3), $geometryCollectionPoints[1]);
99100
}
100101

101-
public function testInvalidGeoJsonException() {
102+
public function testInvalidGeoJsonException()
103+
{
102104
$this->setExpectedException(\Grimzy\LaravelMysqlSpatial\Exceptions\InvalidGeoJsonException::class);
103105
GeometryCollection::fromJson('{"type":"Point","coordinates":[3.4,1.2]}');
104106
}

tests/Unit/Types/GeometryTest.php

+9-6
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,8 @@ public function testFromJsonMultiLineString()
123123
$this->assertEquals(new Point(3, 2), $multiLineStringLineStrings[1][2]);
124124
}
125125

126-
public function testFromJsonMultiPolygon() {
126+
public function testFromJsonMultiPolygon()
127+
{
127128
$multiPolygon = Geometry::fromJson('{"type":"MultiPolygon","coordinates":[[[[1,1],[1,2],[2,2],[2,1],[1,1]]],[[[0,0],[0,1],[1,1],[1,0],[0,0]]]]}');
128129
$this->assertInstanceOf(MultiPolygon::class, $multiPolygon);
129130
$multiPolygonPolygons = $multiPolygon->getGeometries();
@@ -133,25 +134,27 @@ public function testFromJsonMultiPolygon() {
133134
new Point(2, 1),
134135
new Point(2, 2),
135136
new Point(1, 2),
136-
new Point(1, 1)
137+
new Point(1, 1),
137138
])]), $multiPolygonPolygons[0]);
138139
$this->assertEquals(new Polygon([new LineString([
139140
new Point(0, 0),
140141
new Point(1, 0),
141142
new Point(1, 1),
142143
new Point(0, 1),
143-
new Point(0, 0)
144+
new Point(0, 0),
144145
])]), $multiPolygonPolygons[1]);
145146
}
146147

147-
public function testFromJsonPointFeature() {
148+
public function testFromJsonPointFeature()
149+
{
148150
$point = Geometry::fromJson('{"type":"Feature","properties":{},"geometry":{"type":"Point","coordinates":[3.4,1.2]}}');
149151
$this->assertInstanceOf(Point::class, $point);
150152
$this->assertEquals(1.2, $point->getLat());
151153
$this->assertEquals(3.4, $point->getLng());
152154
}
153-
154-
public function testFromJsonMultiPointFeatureCollection() {
155+
156+
public function testFromJsonMultiPointFeatureCollection()
157+
{
155158
$geometryCollection = Geometry::fromJson('{"type":"FeatureCollection","features":[{"type":"Feature","properties":{},"geometry":{"type":"Point","coordinates":[1,2]}},{"type":"Feature","properties":{},"geometry":{"type":"Point","coordinates":[3,4]}}]}');
156159
$this->assertInstanceOf(GeometryCollection::class, $geometryCollection);
157160
$geometryCollectionPoints = $geometryCollection->getGeometries();

tests/Unit/Types/LineStringTest.php

+4-2
Original file line numberDiff line numberDiff line change
@@ -34,15 +34,17 @@ public function testToString()
3434
$this->assertEquals('0 0,1 1,2 2', (string) $linestring);
3535
}
3636

37-
public function testFromJson() {
37+
public function testFromJson()
38+
{
3839
$lineString = LineString::fromJson('{"type": "LineString","coordinates":[[1,1],[2,2]]}');
3940
$this->assertInstanceOf(LineString::class, $lineString);
4041
$lineStringPoints = $lineString->getGeometries();
4142
$this->assertEquals(new Point(1, 1), $lineStringPoints[0]);
4243
$this->assertEquals(new Point(2, 2), $lineStringPoints[1]);
4344
}
4445

45-
public function testInvalidGeoJsonException() {
46+
public function testInvalidGeoJsonException()
47+
{
4648
$this->setExpectedException(\Grimzy\LaravelMysqlSpatial\Exceptions\InvalidGeoJsonException::class);
4749
LineString::fromJson('{"type":"Point","coordinates":[3.4,1.2]}');
4850
}

tests/Unit/Types/MultiLineStringTest.php

+4-2
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,8 @@ public function testToWKT()
2929
$this->assertSame('MULTILINESTRING((0 0,1 0,1 1,0 1,0 0))', $multilinestring->toWKT());
3030
}
3131

32-
public function testFromJson() {
32+
public function testFromJson()
33+
{
3334
$multiLineString = MultiLineString::fromJson('{"type":"MultiLineString","coordinates":[[[1,1],[1,2],[1,3]],[[2,1],[2,2],[2,3]]]}');
3435
$this->assertInstanceOf(MultiLineString::class, $multiLineString);
3536
$multiLineStringLineStrings = $multiLineString->getGeometries();
@@ -42,7 +43,8 @@ public function testFromJson() {
4243
$this->assertEquals(new Point(3, 2), $multiLineStringLineStrings[1][2]);
4344
}
4445

45-
public function testInvalidGeoJsonException() {
46+
public function testInvalidGeoJsonException()
47+
{
4648
$this->setExpectedException(\Grimzy\LaravelMysqlSpatial\Exceptions\InvalidGeoJsonException::class);
4749
MultiLineString::fromJson('{"type":"Point","coordinates":[3.4,1.2]}');
4850
}

0 commit comments

Comments
 (0)