Completed
Push — master ( 0a581b...48954a )
by Christophe
24:56 queued 11:56
created
src/SortedCollection/SubMap.php 1 patch
Braces   +16 added lines, -32 removed lines patch added patch discarded remove patch
@@ -122,8 +122,7 @@  discard block
 block discarded – undo
122 122
 				if ($this->fromOption == self::UNUSED)
123 123
 				{
124 124
 					throw new \RuntimeException('Undefined property');
125
-				}
126
-				else
125
+				} else
127 126
 				{
128 127
 					return $this->fromKey;
129 128
 				}
@@ -132,8 +131,7 @@  discard block
 block discarded – undo
132 131
 				if ($this->toOption == self::UNUSED)
133 132
 				{
134 133
 					throw new \RuntimeException('Undefined property');
135
-				}
136
-				else
134
+				} else
137 135
 				{
138 136
 					return $this->toKey;
139 137
 				}
@@ -142,8 +140,7 @@  discard block
 block discarded – undo
142 140
 				if ($this->fromOption == self::UNUSED)
143 141
 				{
144 142
 					throw new \RuntimeException('Undefined property');
145
-				}
146
-				else
143
+				} else
147 144
 				{
148 145
 					return $this->fromOption == self::INCLUSIVE;
149 146
 				}
@@ -152,8 +149,7 @@  discard block
 block discarded – undo
152 149
 				if ($this->toOption == self::UNUSED)
153 150
 				{
154 151
 					throw new \RuntimeException('Undefined property');
155
-				}
156
-				else
152
+				} else
157 153
 				{
158 154
 					return $this->toOption == self::INCLUSIVE;
159 155
 				}
@@ -201,8 +197,7 @@  discard block
 block discarded – undo
201 197
 				if ($this->fromOption == self::UNUSED)
202 198
 				{
203 199
 					throw new \RuntimeException('Undefined property');
204
-				}
205
-				else
200
+				} else
206 201
 				{
207 202
 					$this->fromOption = $value ? self::INCLUSIVE : self::EXCLUSIVE;
208 203
 				}
@@ -211,8 +206,7 @@  discard block
 block discarded – undo
211 206
 				if ($this->toOption == self::UNUSED)
212 207
 				{
213 208
 					throw new \RuntimeException('Undefined property');
214
-				}
215
-				else
209
+				} else
216 210
 				{
217 211
 					$this->toOption = $value ? self::INCLUSIVE : self::EXCLUSIVE;
218 212
 				}
@@ -311,8 +305,7 @@  discard block
 block discarded – undo
311 305
 			$cmp = call_user_func($this->map->comparator(), $this->fromKey, $this->toKey);
312 306
 
313 307
 			$this->empty = $cmp > 0 || $cmp == 0 && ($this->fromOption == self::EXCLUSIVE || $this->toOption == self::EXCLUSIVE);
314
-		}
315
-		else
308
+		} else
316 309
 		{
317 310
 			$this->empty = false;
318 311
 		}
@@ -565,8 +558,7 @@  discard block
 block discarded – undo
565 558
 				if (call_user_func($this->map->comparator(), $key, $this->fromKey) <= 0)
566 559
 				{
567 560
 					throw new \OutOfBoundsException('Lower element unexisting');
568
-				}
569
-				else
561
+				} else
570 562
 				{
571 563
 					$lower = $this->map->lower($key);
572 564
 
@@ -624,8 +616,7 @@  discard block
 block discarded – undo
624 616
 				if (call_user_func($this->map->comparator(), $key, $this->fromKey) < 0)
625 617
 				{
626 618
 					throw new \OutOfBoundsException('Floor element unexisting');
627
-				}
628
-				else
619
+				} else
629 620
 				{
630 621
 					$floor = $this->map->floor($key);
631 622
 				}
@@ -634,8 +625,7 @@  discard block
 block discarded – undo
634 625
 				if (call_user_func($this->map->comparator(), $key, $this->fromKey) <= 0)
635 626
 				{
636 627
 					throw new \OutOfBoundsException('Floor element unexisting');
637
-				}
638
-				else
628
+				} else
639 629
 				{
640 630
 					$floor = $this->map->floor($key);
641 631
 				}
@@ -739,8 +729,7 @@  discard block
 block discarded – undo
739 729
 				if (call_user_func($this->map->comparator(), $key, $this->toKey) > 0)
740 730
 				{
741 731
 					throw new \OutOfBoundsException('Ceiling element unexisting');
742
-				}
743
-				else
732
+				} else
744 733
 				{
745 734
 					$ceiling = $this->map->ceiling($key);
746 735
 				}
@@ -749,8 +738,7 @@  discard block
 block discarded – undo
749 738
 				if (call_user_func($this->map->comparator(), $key, $this->toKey) >= 0)
750 739
 				{
751 740
 					throw new \OutOfBoundsException('Ceiling element unexisting');
752
-				}
753
-				else
741
+				} else
754 742
 				{
755 743
 					$ceiling = $this->map->ceiling($key);
756 744
 				}
@@ -809,8 +797,7 @@  discard block
 block discarded – undo
809 797
 				if (call_user_func($this->map->comparator(), $key, $this->toKey) >= 0)
810 798
 				{
811 799
 					throw new \OutOfBoundsException('Higher element unexisting');
812
-				}
813
-				else
800
+				} else
814 801
 				{
815 802
 					$higher = $this->map->higher($key);
816 803
 
@@ -862,8 +849,7 @@  discard block
 block discarded – undo
862 849
 						'map' => $this->map->jsonSerialize(),
863 850
 					)
864 851
 				);
865
-			}
866
-			else
852
+			} else
867 853
 			{
868 854
 				return array(
869 855
 					'HeadMap' => array(
@@ -873,8 +859,7 @@  discard block
 block discarded – undo
873 859
 					)
874 860
 				);
875 861
 			}
876
-		}
877
-		else
862
+		} else
878 863
 		{
879 864
 			if ($this->toOption == self::UNUSED)
880 865
 			{
@@ -885,8 +870,7 @@  discard block
 block discarded – undo
885 870
 						'fromInclusive' => $this->fromOption == self::INCLUSIVE,
886 871
 					)
887 872
 				);
888
-			}
889
-			else
873
+			} else
890 874
 			{
891 875
 				return array(
892 876
 					'SubMap' => array(
Please login to merge, or discard this patch.
src/SortedCollection/SubSet.php 1 patch
Braces   +6 added lines, -12 removed lines patch added patch discarded remove patch
@@ -199,17 +199,14 @@  discard block
 block discarded – undo
199 199
 			if ($toOption == self::UNUSED)
200 200
 			{
201 201
 				$this->setMap(SubMap::view($set->getMap()));
202
-			}
203
-			else
202
+			} else
204 203
 			{
205 204
 				$this->setMap(SubMap::head($set->getMap(), $to, $toOption == self::INCLUSIVE));
206 205
 			}
207
-		}
208
-		elseif ($toOption == self::UNUSED)
206
+		} elseif ($toOption == self::UNUSED)
209 207
 		{
210 208
 			$this->setMap(SubMap::tail($set->getMap(), $from, $fromOption == self::INCLUSIVE));
211
-		}
212
-		else
209
+		} else
213 210
 		{
214 211
 			$this->setMap(SubMap::create($set->getMap(), $from, $to, $fromOption == self::INCLUSIVE, $toOption == self::INCLUSIVE));
215 212
 		}
@@ -303,8 +300,7 @@  discard block
 block discarded – undo
303 300
 						'toInclusive' => $this->toInclusive,
304 301
 					)
305 302
 				);
306
-			}
307
-			else
303
+			} else
308 304
 			{
309 305
 				return array(
310 306
 					'TailSet' => array(
@@ -314,8 +310,7 @@  discard block
 block discarded – undo
314 310
 					)
315 311
 				);
316 312
 			}
317
-		}
318
-		else
313
+		} else
319 314
 		{
320 315
 			if (isset($this->to))
321 316
 			{
@@ -326,8 +321,7 @@  discard block
 block discarded – undo
326 321
 						'toInclusive' => $this->toInclusive,
327 322
 					)
328 323
 				);
329
-			}
330
-			else
324
+			} else
331 325
 			{
332 326
 				return array(
333 327
 					'ViewSet' => array(
Please login to merge, or discard this patch.
src/SortedCollection/TreeNode.php 2 patches
Braces   +28 added lines, -56 removed lines patch added patch discarded remove patch
@@ -189,8 +189,7 @@  discard block
 block discarded – undo
189 189
 			}
190 190
 
191 191
 			return $node;
192
-		}
193
-		else
192
+		} else
194 193
 		{
195 194
 			return $this->left;
196 195
 		}
@@ -215,8 +214,7 @@  discard block
 block discarded – undo
215 214
 			}
216 215
 
217 216
 			return $node;
218
-		}
219
-		else
217
+		} else
220 218
 		{
221 219
 			return $this->right;
222 220
 		}
@@ -273,12 +271,10 @@  discard block
 block discarded – undo
273 271
 			if ($cmp < 0 && $node->information & 2)
274 272
 			{
275 273
 				$node = $node->left;
276
-			}
277
-			elseif ($cmp > 0 && $node->information & 1)
274
+			} elseif ($cmp > 0 && $node->information & 1)
278 275
 			{
279 276
 				$node = $node->right;
280
-			}
281
-			else
277
+			} else
282 278
 			{
283 279
 				break;
284 280
 			}
@@ -289,42 +285,34 @@  discard block
 block discarded – undo
289 285
 			if ($type < 0)
290 286
 			{
291 287
 				return $node->left;
292
-			}
293
-			elseif ($type > 0)
288
+			} elseif ($type > 0)
294 289
 			{
295 290
 				return $node;
296
-			}
297
-			else
291
+			} else
298 292
 			{
299 293
 				return null;
300 294
 			}
301
-		}
302
-		elseif ($cmp > 0)
295
+		} elseif ($cmp > 0)
303 296
 		{
304 297
 			if ($type < 0)
305 298
 			{
306 299
 				return $node;
307
-			}
308
-			elseif ($type > 0)
300
+			} elseif ($type > 0)
309 301
 			{
310 302
 				return $node->right;
311
-			}
312
-			else
303
+			} else
313 304
 			{
314 305
 				return null;
315 306
 			}
316
-		}
317
-		else
307
+		} else
318 308
 		{
319 309
 			if ($type < -1)
320 310
 			{
321 311
 				return $node->predecessor;
322
-			}
323
-			elseif ($type > 1)
312
+			} elseif ($type > 1)
324 313
 			{
325 314
 				return $node->successor;
326
-			}
327
-			else
315
+			} else
328 316
 			{
329 317
 				return $node;
330 318
 			}
@@ -346,8 +334,7 @@  discard block
 block discarded – undo
346 334
 		{
347 335
 			$this->right = $right->left;
348 336
 			$right->left = $this;
349
-		}
350
-		else
337
+		} else
351 338
 		{
352 339
 			$right->information |= 2;
353 340
 			$this->information &= ~ 1;
@@ -385,8 +372,7 @@  discard block
 block discarded – undo
385 372
 		{
386 373
 			$this->left = $left->right;
387 374
 			$left->right = $this;
388
-		}
389
-		else
375
+		} else
390 376
 		{
391 377
 			$this->information &= ~ 2;
392 378
 			$left->information |= 1;
@@ -484,15 +470,13 @@  discard block
 block discarded – undo
484 470
 				{
485 471
 					$node = $this->decBalance();
486 472
 				}
487
-			}
488
-			else
473
+			} else
489 474
 			{
490 475
 				$this->left = new static($key, $value, $this->left, $this);
491 476
 				$this->information |= 2;
492 477
 				$node = $this->decBalance();
493 478
 			}
494
-		}
495
-		elseif ($cmp > 0)
479
+		} elseif ($cmp > 0)
496 480
 		{
497 481
 			if ($this->information & 1)
498 482
 			{
@@ -503,15 +487,13 @@  discard block
 block discarded – undo
503 487
 				{
504 488
 					$node = $this->incBalance();
505 489
 				}
506
-			}
507
-			else
490
+			} else
508 491
 			{
509 492
 				$this->right = new static($key, $value, $this, $this->right);
510 493
 				$this->information |= 1;
511 494
 				$node = $this->incBalance();
512 495
 			}
513
-		}
514
-		else
496
+		} else
515 497
 		{
516 498
 			$this->value = $value;
517 499
 		}
@@ -536,13 +518,11 @@  discard block
 block discarded – undo
536 518
 			if (!($this->information & 2) || $leftBalance != 0 && ($this->left->information & ~3) == 0)
537 519
 			{
538 520
 				return $this->incBalance();
539
-			}
540
-			else
521
+			} else
541 522
 			{
542 523
 				return $this;
543 524
 			}
544
-		}
545
-		else
525
+		} else
546 526
 		{
547 527
 			$this->left->key = $this->key;
548 528
 			$this->left->value = $this->value;
@@ -552,16 +532,14 @@  discard block
 block discarded – undo
552 532
 				$this->right->left = $this->left;
553 533
 
554 534
 				return $this->right;
555
-			}
556
-			else
535
+			} else
557 536
 			{
558 537
 				if ($this->left->right == $this)
559 538
 				{
560 539
 					$this->left->information &= ~ 1;
561 540
 
562 541
 					return $this->right;
563
-				}
564
-				else
542
+				} else
565 543
 				{
566 544
 					$this->right->information &= ~ 2;
567 545
 
@@ -597,8 +575,7 @@  discard block
 block discarded – undo
597 575
 					return $this->incBalance();
598 576
 				}
599 577
 			}
600
-		}
601
-		elseif ($cmp > 0)
578
+		} elseif ($cmp > 0)
602 579
 		{
603 580
 			if ($this->information & 1)
604 581
 			{
@@ -610,8 +587,7 @@  discard block
 block discarded – undo
610 587
 					return $this->decBalance();
611 588
 				}
612 589
 			}
613
-		}
614
-		else
590
+		} else
615 591
 		{
616 592
 			if ($this->information & 1)
617 593
 			{
@@ -622,8 +598,7 @@  discard block
 block discarded – undo
622 598
 				{
623 599
 					return $this->decBalance();
624 600
 				}
625
-			}
626
-			else
601
+			} else
627 602
 			{
628 603
 				$left = $this->left;
629 604
 				$right = $this->right;
@@ -633,22 +608,19 @@  discard block
 block discarded – undo
633 608
 					$left->right = $right;
634 609
 
635 610
 					return $left;
636
-				}
637
-				else
611
+				} else
638 612
 				{
639 613
 					if ($left && $left->right == $this)
640 614
 					{
641 615
 						$left->information &= ~ 1;
642 616
 
643 617
 						return $right;
644
-					}
645
-					elseif ($right && $right->left == $this)
618
+					} elseif ($right && $right->left == $this)
646 619
 					{
647 620
 						$right->information &= ~ 2;
648 621
 
649 622
 						return $left;
650
-					}
651
-					else
623
+					} else
652 624
 					{
653 625
 						return null;
654 626
 					}
Please login to merge, or discard this patch.
Doc Comments   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -73,7 +73,7 @@  discard block
 block discarded – undo
73 73
 	 * @param mixed $key The node key
74 74
 	 * @param mixed $value The node value
75 75
 	 *
76
-	 * @return A new node
76
+	 * @return TreeNode new node
77 77
 	 *
78 78
 	 * @since 1.0.0
79 79
 	 */
@@ -135,7 +135,7 @@  discard block
 block discarded – undo
135 135
 	/**
136 136
 	 * Get the first node
137 137
 	 *
138
-	 * @return the first node
138
+	 * @return TreeNode first node
139 139
 	 *
140 140
 	 * @since 1.0.0
141 141
 	 */
@@ -154,7 +154,7 @@  discard block
 block discarded – undo
154 154
 	/**
155 155
 	 * Get the last node
156 156
 	 *
157
-	 * @return the last node
157
+	 * @return TreeNode last node
158 158
 	 *
159 159
 	 * @since 1.0.0
160 160
 	 */
@@ -173,7 +173,7 @@  discard block
 block discarded – undo
173 173
 	/**
174 174
 	 * Get the predecessor
175 175
 	 *
176
-	 * @return the predecessor node
176
+	 * @return TreeNode predecessor node
177 177
 	 *
178 178
 	 * @since 1.0.0
179 179
 	 */
@@ -199,7 +199,7 @@  discard block
 block discarded – undo
199 199
 	/**
200 200
 	 * Get the successor
201 201
 	 *
202
-	 * @return the successor node
202
+	 * @return TreeNode successor node
203 203
 	 *
204 204
 	 * @since 1.0.0
205 205
 	 */
@@ -258,7 +258,7 @@  discard block
 block discarded – undo
258 258
 	 *                      +1 for the lowest key greater than or equal to the given key
259 259
 	 *                      +2 for the lowest key greater than the given key
260 260
 	 *
261
-	 * @return mixed The node or null if not found
261
+	 * @return TreeNode|null The node or null if not found
262 262
 	 *
263 263
 	 * @since 1.0.0
264 264
 	 */
Please login to merge, or discard this patch.
examples/TreeMap.php 1 patch
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -14,43 +14,43 @@
 block discarded – undo
14 14
  * This file is part of the php-sorted-collections package https://github.com/chdemko/php-sorted-collections
15 15
  */
16 16
 
17
-require __DIR__ . '/../vendor/autoload.php';
17
+require __DIR__.'/../vendor/autoload.php';
18 18
 
19 19
 use chdemko\SortedCollection\TreeMap;
20 20
 
21 21
 $tree = TreeMap::create()->put(array(1 => 1, 9 => 9, 5 => 5, 2 => 2, 6 => 6, 3 => 3, 0 => 0, 8 => 8, 7 => 7, 4 => 4));
22 22
 
23 23
 // Print [0,1,2,3,4,5,6,7,8,9]
24
-echo $tree . PHP_EOL;
24
+echo $tree.PHP_EOL;
25 25
 
26 26
 // Print 0
27
-echo $tree->firstKey . PHP_EOL;
27
+echo $tree->firstKey.PHP_EOL;
28 28
 
29 29
 // Print 9
30
-echo $tree->lastValue . PHP_EOL;
30
+echo $tree->lastValue.PHP_EOL;
31 31
 
32 32
 // Print 10
33
-echo count($tree) . PHP_EOL;
33
+echo count($tree).PHP_EOL;
34 34
 
35 35
 // Print 5
36
-echo $tree[5] . PHP_EOL;
36
+echo $tree[5].PHP_EOL;
37 37
 
38 38
 // Change value for $tree[5]
39 39
 $tree[5] = 10;
40 40
 
41 41
 // Print [0,1,2,3,4,10,6,7,8,9]
42
-echo $tree . PHP_EOL;
42
+echo $tree.PHP_EOL;
43 43
 
44 44
 // Unset $tree[5]
45 45
 unset($tree[5]);
46 46
 
47 47
 // Print {"0":0,"1":1,"2":2,"3":3,"4":4,"6":6,"7":7,"8":8,"9":9}
48
-echo $tree . PHP_EOL;
48
+echo $tree.PHP_EOL;
49 49
 
50 50
 // Print 0-0;1-1;2-2;3-3;4-4;6-6;7-7;8-8;9-9;
51 51
 foreach ($tree as $key => $value)
52 52
 {
53
-	echo $key . '-' . $value . ';';
53
+	echo $key.'-'.$value.';';
54 54
 }
55 55
 
56 56
 echo PHP_EOL;
Please login to merge, or discard this patch.
examples/TreeSet.php 1 patch
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -14,43 +14,43 @@
 block discarded – undo
14 14
  * This file is part of the php-sorted-collections package https://github.com/chdemko/php-sorted-collections
15 15
  */
16 16
 
17
-require __DIR__ . '/../vendor/autoload.php';
17
+require __DIR__.'/../vendor/autoload.php';
18 18
 
19 19
 use chdemko\SortedCollection\TreeSet;
20 20
 
21 21
 $set = TreeSet::create()->put(array(1, 9, 5, 2, 6, 3, 0, 8, 7, 4));
22 22
 
23 23
 // Print [0,1,2,3,4,5,6,7,8,9]
24
-echo $set . PHP_EOL;
24
+echo $set.PHP_EOL;
25 25
 
26 26
 // Print 0
27
-echo $set->first . PHP_EOL;
27
+echo $set->first.PHP_EOL;
28 28
 
29 29
 // Print 9
30
-echo $set->last . PHP_EOL;
30
+echo $set->last.PHP_EOL;
31 31
 
32 32
 // Print 10
33
-echo count($set) . PHP_EOL;
33
+echo count($set).PHP_EOL;
34 34
 
35 35
 // Print 1
36
-echo $set[5] . PHP_EOL;
36
+echo $set[5].PHP_EOL;
37 37
 
38 38
 // Change value for $set[5]
39 39
 $set[5] = false;
40 40
 
41 41
 // Print [0,1,2,3,4,6,7,8,9]
42
-echo $set . PHP_EOL;
42
+echo $set.PHP_EOL;
43 43
 
44 44
 // Unset $set[6]
45 45
 unset($set[6]);
46 46
 
47 47
 // Print [0,1,2,3,4,7,8,9]
48
-echo $set . PHP_EOL;
48
+echo $set.PHP_EOL;
49 49
 
50 50
 // Print 0-0;1-1;2-2;3-3;4-4;5-7;6-8;7-9;
51 51
 foreach ($set as $key => $value)
52 52
 {
53
-	echo $key . '-' . $value . ';';
53
+	echo $key.'-'.$value.';';
54 54
 }
55 55
 
56 56
 echo PHP_EOL;
Please login to merge, or discard this patch.
benchmarks/TreeMap.php 1 patch
Braces   +4 added lines, -8 removed lines patch added patch discarded remove patch
@@ -105,8 +105,7 @@  discard block
 block discarded – undo
105 105
 							(int) ($params['from'] * $params['count']),
106 106
 							(int) ($params['to'] * $params['count'])
107 107
 						);
108
-					}
109
-					else
108
+					} else
110 109
 					{
111 110
 						$this->data = chdemko\SortedCollection\SubMap::create(
112 111
 							$this->tree,
@@ -116,8 +115,7 @@  discard block
 block discarded – undo
116 115
 					}
117 116
 				break;
118 117
 			}
119
-		}
120
-		else
118
+		} else
121 119
 		{
122 120
 			$this->data = $this->tree;
123 121
 		}
@@ -174,8 +172,7 @@  discard block
 block discarded – undo
174 172
 		if (isset($params['from']))
175 173
 		{
176 174
 			$min = (int) ($params['from'] * $params['count']);
177
-		}
178
-		else
175
+		} else
179 176
 		{
180 177
 			$min = 0;
181 178
 		}
@@ -183,8 +180,7 @@  discard block
 block discarded – undo
183 180
 		if (isset($params['to']))
184 181
 		{
185 182
 			$max = (int) ($params['to'] * $params['count']);
186
-		}
187
-		else
183
+		} else
188 184
 		{
189 185
 			$max = $params['count'];
190 186
 		}
Please login to merge, or discard this patch.