Passed
Push — master ( 3be7cd...21bbb1 )
by smiley
01:30
created
src/GeoJSONException.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -12,4 +12,4 @@
 block discarded – undo
12 12
 
13 13
 namespace chillerlan\GeoJSON;
14 14
 
15
-class GeoJSONException extends \Exception{}
15
+class GeoJSONException extends \Exception {}
Please login to merge, or discard this patch.
src/PolylineSimplifyer.php 2 patches
Braces   +1 added lines, -2 removed lines patch added patch discarded remove patch
@@ -155,8 +155,7 @@
 block discarded – undo
155 155
 				$x = $p2[0];
156 156
 				$y = $p2[1];
157 157
 
158
-			}
159
-			elseif($t > 0){
158
+			} elseif($t > 0){
160 159
 				$x += $dx * $t;
161 160
 				$y += $dy * $t;
162 161
 			}
Please login to merge, or discard this patch.
Spacing   +17 added lines, -17 removed lines patch added patch discarded remove patch
@@ -15,7 +15,7 @@  discard block
 block discarded – undo
15 15
 /**
16 16
  * @see https://github.com/mourner/simplify-js
17 17
  */
18
-class PolylineSimplifyer{
18
+class PolylineSimplifyer {
19 19
 
20 20
 	protected array $coords;
21 21
 
@@ -24,17 +24,17 @@  discard block
 block discarded – undo
24 24
 	 *
25 25
 	 * @throws \chillerlan\GeoJSON\GeoJSONException
26 26
 	 */
27
-	public function __construct(array $polylineCoords){
27
+	public function __construct(array $polylineCoords) {
28 28
 
29
-		if(count($polylineCoords) < 2){
29
+		if (count($polylineCoords) < 2) {
30 30
 			throw new GeoJSONException('not enough points');
31 31
 		}
32 32
 
33 33
 		$this->coords = array_values($polylineCoords);
34 34
 
35
-		foreach($this->coords as $i => $coord){
35
+		foreach ($this->coords as $i => $coord) {
36 36
 
37
-			if(!is_array($coord) || count($coord) < 2){
37
+			if (!is_array($coord) || count($coord) < 2) {
38 38
 				throw new GeoJSONException('invalid coords found');
39 39
 			}
40 40
 
@@ -62,16 +62,16 @@  discard block
 block discarded – undo
62 62
 		$point     = null;
63 63
 		$len       = count($this->coords);
64 64
 
65
-		for($i = 1; $i < $len; $i++){
65
+		for ($i = 1; $i < $len; $i++) {
66 66
 			$point = $this->coords[$i];
67 67
 
68
-			if($this->getSqDist($point, $prevPoint) > $sqTolerance){
68
+			if ($this->getSqDist($point, $prevPoint) > $sqTolerance) {
69 69
 				$newPoints[] = $point;
70 70
 				$prevPoint   = $point;
71 71
 			}
72 72
 		}
73 73
 
74
-		if($prevPoint !== $point){
74
+		if ($prevPoint !== $point) {
75 75
 			$newPoints[] = $point;
76 76
 		}
77 77
 
@@ -102,20 +102,20 @@  discard block
 block discarded – undo
102 102
 
103 103
 		$markers[$first] = $markers[$last] = 1;
104 104
 
105
-		while($last){
105
+		while ($last) {
106 106
 
107 107
 			$maxSqDist = 0;
108 108
 
109
-			for($i = $first + 1; $i < $last; $i++){
109
+			for ($i = $first + 1; $i < $last; $i++) {
110 110
 				$sqDist = $this->getSqSegDist($points[$i], $points[$first], $points[$last]);
111 111
 
112
-				if($sqDist > $maxSqDist){
112
+				if ($sqDist > $maxSqDist) {
113 113
 					$index     = $i;
114 114
 					$maxSqDist = $sqDist;
115 115
 				}
116 116
 			}
117 117
 
118
-			if($maxSqDist > $sqTolerance){
118
+			if ($maxSqDist > $sqTolerance) {
119 119
 				$markers[$index] = 1;
120 120
 				array_push($stack, $first, $index, $index, $last);
121 121
 			}
@@ -124,8 +124,8 @@  discard block
 block discarded – undo
124 124
 			$first = array_pop($stack);
125 125
 		}
126 126
 
127
-		foreach($points as $i => $point){
128
-			if($markers[$i]){
127
+		foreach ($points as $i => $point) {
128
+			if ($markers[$i]) {
129 129
 				$newPoints[] = $point;
130 130
 			}
131 131
 		}
@@ -142,16 +142,16 @@  discard block
 block discarded – undo
142 142
 		$dx = $p2[0] - $x;
143 143
 		$dy = $p2[1] - $y;
144 144
 
145
-		if((int)$dx !== 0 || (int)$dy !== 0){
145
+		if ((int) $dx !== 0 || (int) $dy !== 0) {
146 146
 
147 147
 			$t = (($p[0] - $x) * $dx + ($p[1] - $y) * $dy) / ($dx * $dx + $dy * $dy);
148 148
 
149
-			if($t > 1){
149
+			if ($t > 1) {
150 150
 				$x = $p2[0];
151 151
 				$y = $p2[1];
152 152
 
153 153
 			}
154
-			elseif($t > 0){
154
+			elseif ($t > 0) {
155 155
 				$x += $dx * $t;
156 156
 				$y += $dy * $t;
157 157
 			}
Please login to merge, or discard this patch.
src/ContinentRect.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -10,7 +10,7 @@  discard block
 block discarded – undo
10 10
 
11 11
 namespace chillerlan\GeoJSON;
12 12
 
13
-class ContinentRect{
13
+class ContinentRect {
14 14
 
15 15
 	protected array $rect;
16 16
 
@@ -19,7 +19,7 @@  discard block
 block discarded – undo
19 19
 	 *
20 20
 	 * @param array $continent_rect (NW/SE corners [[nw_x, nw_y],[se_x, se_y]])
21 21
 	 */
22
-	public function __construct(array $continent_rect){
22
+	public function __construct(array $continent_rect) {
23 23
 		$this->rect = $continent_rect;
24 24
 	}
25 25
 
Please login to merge, or discard this patch.
src/GeoJSONAbstract.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -15,7 +15,7 @@  discard block
 block discarded – undo
15 15
 use function in_array;
16 16
 use function json_encode;
17 17
 
18
-abstract class GeoJSONAbstract implements JsonSerializable{
18
+abstract class GeoJSONAbstract implements JsonSerializable {
19 19
 
20 20
 	protected array $bbox;
21 21
 
@@ -24,7 +24,7 @@  discard block
 block discarded – undo
24 24
 	 */
25 25
 	public function setBbox(array $bbox):GeoJSONAbstract{
26 26
 
27
-		if(!in_array(count($bbox), [4, 6], true)){
27
+		if (!in_array(count($bbox), [4, 6], true)) {
28 28
 			throw new GeoJSONException('invalid bounding box array');
29 29
 		}
30 30
 
Please login to merge, or discard this patch.
src/FeatureCollection.php 1 patch
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -15,7 +15,7 @@  discard block
 block discarded – undo
15 15
 /**
16 16
  * @see https://www.rfc-editor.org/rfc/rfc7946#section-3.3
17 17
  */
18
-class FeatureCollection extends GeoJSONAbstract{
18
+class FeatureCollection extends GeoJSONAbstract {
19 19
 
20 20
 	/** @var \chillerlan\GeoJSON\Feature[] */
21 21
 	protected array $features = [];
@@ -25,9 +25,9 @@  discard block
 block discarded – undo
25 25
 	 *
26 26
 	 * @param \chillerlan\GeoJSON\Feature[]|null $features
27 27
 	 */
28
-	public function __construct(iterable $features = null){
28
+	public function __construct(iterable $features = null) {
29 29
 
30
-		if(!empty($features)){
30
+		if (!empty($features)) {
31 31
 			$this->addFeatures($features);
32 32
 		}
33 33
 
@@ -47,8 +47,8 @@  discard block
 block discarded – undo
47 47
 	 */
48 48
 	public function addFeatures(iterable $features):FeatureCollection{
49 49
 
50
-		foreach($features as $feature){
51
-			if($feature instanceof Feature){
50
+		foreach ($features as $feature) {
51
+			if ($feature instanceof Feature) {
52 52
 				$this->addFeature($feature);
53 53
 			}
54 54
 		}
@@ -71,7 +71,7 @@  discard block
 block discarded – undo
71 71
 	public function toArray():array{
72 72
 		$arr = ['type' => 'FeatureCollection'];
73 73
 
74
-		if(!empty($this->bbox)){
74
+		if (!empty($this->bbox)) {
75 75
 			$arr['bbox'] = $this->bbox;
76 76
 		}
77 77
 
Please login to merge, or discard this patch.
src/Feature.php 1 patch
Spacing   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -17,7 +17,7 @@  discard block
 block discarded – undo
17 17
 /**
18 18
  * @see https://www.rfc-editor.org/rfc/rfc7946#section-3.2
19 19
  */
20
-class Feature extends GeoJSONAbstract{
20
+class Feature extends GeoJSONAbstract {
21 21
 
22 22
 	public const types = [
23 23
 		'Point',
@@ -44,18 +44,18 @@  discard block
 block discarded – undo
44 44
 	 *
45 45
 	 * @throws \chillerlan\GeoJSON\GeoJSONException
46 46
 	 */
47
-	public function __construct(array $coords = null, string $type = null, $id = null){
47
+	public function __construct(array $coords = null, string $type = null, $id = null) {
48 48
 
49
-		if($coords !== null){
49
+		if ($coords !== null) {
50 50
 
51
-			if($type === null){
51
+			if ($type === null) {
52 52
 				throw new GeoJSONException('got coords but no feature type');
53 53
 			}
54 54
 
55 55
 			$this->setGeometry($coords, $type);
56 56
 		}
57 57
 
58
-		if($id !== null){
58
+		if ($id !== null) {
59 59
 			$this->setID($id);
60 60
 		}
61 61
 
@@ -66,11 +66,11 @@  discard block
 block discarded – undo
66 66
 	 */
67 67
 	public function setGeometry(array $coords, string $type):Feature{
68 68
 
69
-		if(empty($coords)){
69
+		if (empty($coords)) {
70 70
 			throw new GeoJSONException('invalid coords array');
71 71
 		}
72 72
 
73
-		if(!in_array($type, $this::types, true)){
73
+		if (!in_array($type, $this::types, true)) {
74 74
 			throw new GeoJSONException('invalid geometry type');
75 75
 		}
76 76
 
@@ -96,7 +96,7 @@  discard block
 block discarded – undo
96 96
 	 */
97 97
 	public function setID($id):Feature{
98 98
 
99
-		if(!is_string($id) && !is_int($id)){
99
+		if (!is_string($id) && !is_int($id)) {
100 100
 			throw new GeoJSONException('invalid id');
101 101
 		}
102 102
 
@@ -110,7 +110,7 @@  discard block
 block discarded – undo
110 110
 	 */
111 111
 	public function toArray():array{
112 112
 
113
-		if(empty($this->coords) || empty($this->type)){
113
+		if (empty($this->coords) || empty($this->type)) {
114 114
 			throw new GeoJSONException('invalid feature');
115 115
 		}
116 116
 
@@ -122,15 +122,15 @@  discard block
 block discarded – undo
122 122
 			]
123 123
 		];
124 124
 
125
-		if(!empty($this->bbox)){
125
+		if (!empty($this->bbox)) {
126 126
 			$arr['bbox'] = $this->bbox;
127 127
 		}
128 128
 
129
-		if(!empty($this->properties)){
129
+		if (!empty($this->properties)) {
130 130
 			$arr['properties'] = $this->properties;
131 131
 		}
132 132
 
133
-		if(!empty($this->id)){
133
+		if (!empty($this->id)) {
134 134
 			$arr['properties']['id'] = $this->id; // leaflet
135 135
 #			$arr['id']               = $this->id; // GMaps
136 136
 		}
Please login to merge, or discard this patch.