Passed
Push — master ( 3d4b77...c34803 )
by smiley
01:33
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
@@ -14,14 +14,14 @@  discard block
 block discarded – undo
14 14
 
15 15
 use function array_fill, array_keys, array_pop, array_push, array_values, count, is_array;
16 16
 
17
-class PolylineSimplifyer{
17
+class PolylineSimplifyer {
18 18
 
19 19
 	protected array $coords;
20 20
 
21 21
 	/**
22 22
 	 * PolylineSimplifyer constructor.
23 23
 	 */
24
-	public function __construct(array $polylineCoords){
24
+	public function __construct(array $polylineCoords) {
25 25
 		$this->coords = $polylineCoords;
26 26
 	}
27 27
 
@@ -31,12 +31,12 @@  discard block
 block discarded – undo
31 31
 	public function simplify(float $tolerance = 1, bool $highestQuality = false):array{
32 32
 		$coords = array_values($this->coords ?? []);
33 33
 
34
-		if(count($coords) < 2){
34
+		if (count($coords) < 2) {
35 35
 			throw new GeoJSONException('not enough points');
36 36
 		}
37 37
 
38
-		foreach($this->coords as $coord){
39
-			if(!is_array($coord) || count($coord) < 2){
38
+		foreach ($this->coords as $coord) {
39
+			if (!is_array($coord) || count($coord) < 2) {
40 40
 				throw new GeoJSONException('invalid coords found');
41 41
 			}
42 42
 		}
@@ -56,16 +56,16 @@  discard block
 block discarded – undo
56 56
 		$point     = null;
57 57
 		$len       = count($points);
58 58
 
59
-		for($i = 1; $i < $len; $i++){
59
+		for ($i = 1; $i < $len; $i++) {
60 60
 			$point = $points[$i];
61 61
 
62
-			if($this->getSqDist(array_values($point), array_values($prevPoint)) > $sqTolerance){
62
+			if ($this->getSqDist(array_values($point), array_values($prevPoint)) > $sqTolerance) {
63 63
 				$newPoints[] = $point;
64 64
 				$prevPoint   = $point;
65 65
 			}
66 66
 		}
67 67
 
68
-		if($prevPoint !== $point){
68
+		if ($prevPoint !== $point) {
69 69
 			$newPoints[] = $point;
70 70
 		}
71 71
 
@@ -96,24 +96,24 @@  discard block
 block discarded – undo
96 96
 
97 97
 		$markers[$first] = $markers[$last] = 1;
98 98
 
99
-		while($last){
99
+		while ($last) {
100 100
 
101 101
 			$maxSqDist = 0;
102 102
 
103
-			for($i = $first + 1; $i < $last; $i++){
103
+			for ($i = $first + 1; $i < $last; $i++) {
104 104
 				$sqDist = $this->getSqSegDist(
105 105
 					array_values($points[$i]),
106 106
 					array_values($points[$first]),
107 107
 					array_values($points[$last])
108 108
 				);
109 109
 
110
-				if($sqDist > $maxSqDist){
110
+				if ($sqDist > $maxSqDist) {
111 111
 					$index     = $i;
112 112
 					$maxSqDist = $sqDist;
113 113
 				}
114 114
 			}
115 115
 
116
-			if($maxSqDist > $sqTolerance){
116
+			if ($maxSqDist > $sqTolerance) {
117 117
 				$markers[$index] = 1;
118 118
 				array_push($stack, $first, $index, $index, $last);
119 119
 			}
@@ -122,8 +122,8 @@  discard block
 block discarded – undo
122 122
 			$first = array_pop($stack);
123 123
 		}
124 124
 
125
-		foreach($points as $i => $point){
126
-			if($markers[$i]){
125
+		foreach ($points as $i => $point) {
126
+			if ($markers[$i]) {
127 127
 				$newPoints[] = $point;
128 128
 			}
129 129
 		}
@@ -140,16 +140,16 @@  discard block
 block discarded – undo
140 140
 		$dx = $p2[0] - $x;
141 141
 		$dy = $p2[1] - $y;
142 142
 
143
-		if((int)$dx !== 0 || (int)$dy !== 0){
143
+		if ((int) $dx !== 0 || (int) $dy !== 0) {
144 144
 
145 145
 			$t = (($p[0] - $x) * $dx + ($p[1] - $y) * $dy) / ($dx * $dx + $dy * $dy);
146 146
 
147
-			if($t > 1){
147
+			if ($t > 1) {
148 148
 				$x = $p2[0];
149 149
 				$y = $p2[1];
150 150
 
151 151
 			}
152
-			elseif($t > 0){
152
+			elseif ($t > 0) {
153 153
 				$x += $dx * $t;
154 154
 				$y += $dy * $t;
155 155
 			}
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/FeatureCollection.php 1 patch
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -14,7 +14,7 @@  discard block
 block discarded – undo
14 14
 
15 15
 use function array_map;
16 16
 
17
-class FeatureCollection extends GeoJSONAbstract{
17
+class FeatureCollection extends GeoJSONAbstract {
18 18
 
19 19
 	protected array $features = [];
20 20
 
@@ -23,9 +23,9 @@  discard block
 block discarded – undo
23 23
 	 *
24 24
 	 * @param \chillerlan\GeoJSON\Feature[]|null $features
25 25
 	 */
26
-	public function __construct(iterable $features = null){
26
+	public function __construct(iterable $features = null) {
27 27
 
28
-		if(!empty($features)){
28
+		if (!empty($features)) {
29 29
 			$this->addFeatures($features);
30 30
 		}
31 31
 
@@ -49,8 +49,8 @@  discard block
 block discarded – undo
49 49
 	 */
50 50
 	public function addFeatures(iterable $features):FeatureCollection{
51 51
 
52
-		foreach($features as $feature){
53
-			if($feature instanceof Feature){
52
+		foreach ($features as $feature) {
53
+			if ($feature instanceof Feature) {
54 54
 				$this->addFeature($feature);
55 55
 			}
56 56
 		}
@@ -73,7 +73,7 @@  discard block
 block discarded – undo
73 73
 	public function toArray():array{
74 74
 		$arr = ['type' => 'FeatureCollection'];
75 75
 
76
-		if(!empty($this->bbox)){
76
+		if (!empty($this->bbox)) {
77 77
 			$arr['bbox'] = $this->bbox;
78 78
 		}
79 79
 
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
@@ -16,7 +16,7 @@  discard block
 block discarded – undo
16 16
 use function is_int;
17 17
 use function is_string;
18 18
 
19
-class Feature extends GeoJSONAbstract{
19
+class Feature extends GeoJSONAbstract {
20 20
 
21 21
 	public const types = [
22 22
 		'Point',
@@ -43,18 +43,18 @@  discard block
 block discarded – undo
43 43
 	 *
44 44
 	 * @throws \chillerlan\GeoJSON\GeoJSONException
45 45
 	 */
46
-	public function __construct(array $coords = null, string $type = null, $id = null){
46
+	public function __construct(array $coords = null, string $type = null, $id = null) {
47 47
 
48
-		if($coords !== null){
48
+		if ($coords !== null) {
49 49
 
50
-			if($type === null){
50
+			if ($type === null) {
51 51
 				throw new GeoJSONException('got coords but no feature type');
52 52
 			}
53 53
 
54 54
 			$this->setGeometry($coords, $type);
55 55
 		}
56 56
 
57
-		if($id !== null){
57
+		if ($id !== null) {
58 58
 			$this->setID($id);
59 59
 		}
60 60
 
@@ -65,11 +65,11 @@  discard block
 block discarded – undo
65 65
 	 */
66 66
 	public function setGeometry(array $coords, string $type):Feature{
67 67
 
68
-		if(empty($coords)){
68
+		if (empty($coords)) {
69 69
 			throw new GeoJSONException('invalid coords array');
70 70
 		}
71 71
 
72
-		if(!in_array($type, $this::types, true)){
72
+		if (!in_array($type, $this::types, true)) {
73 73
 			throw new GeoJSONException('invalid geometry type');
74 74
 		}
75 75
 
@@ -95,7 +95,7 @@  discard block
 block discarded – undo
95 95
 	 */
96 96
 	public function setID($id):Feature{
97 97
 
98
-		if(!is_string($id) && !is_int($id)){
98
+		if (!is_string($id) && !is_int($id)) {
99 99
 			throw new GeoJSONException('invalid id');
100 100
 		}
101 101
 
@@ -110,7 +110,7 @@  discard block
 block discarded – undo
110 110
 	public function toArray():array{
111 111
 		$arr = ['type' => 'Feature'];
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
 
@@ -119,15 +119,15 @@  discard block
 block discarded – undo
119 119
 			'coordinates' => $this->coords,
120 120
 		];
121 121
 
122
-		if(!empty($this->bbox)){
122
+		if (!empty($this->bbox)) {
123 123
 			$arr['bbox'] = $this->bbox;
124 124
 		}
125 125
 
126
-		if(!empty($this->properties)){
126
+		if (!empty($this->properties)) {
127 127
 			$arr['properties'] = $this->properties;
128 128
 		}
129 129
 
130
-		if(!empty($this->id)){
130
+		if (!empty($this->id)) {
131 131
 			$arr['properties']['id'] = $this->id; // leaflet
132 132
 #			$arr['id']               = $this->id; // GMaps
133 133
 		}
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.