@@ -1,7 +1,7 @@ |
||
| 1 | 1 | <?php |
| 2 | 2 | |
| 3 | 3 | // if library is in dev environement with its own vendor, include its autoload |
| 4 | -if(file_exists(__DIR__ . '/vendor')) |
|
| 4 | +if (file_exists(__DIR__ . '/vendor')) |
|
| 5 | 5 | require_once __DIR__ . '/vendor/autoload.php'; |
| 6 | 6 | // if library is in vendor of another project, include the global autolaod |
| 7 | 7 | else |
@@ -1,8 +1,10 @@ |
||
| 1 | 1 | <?php |
| 2 | 2 | |
| 3 | 3 | // if library is in dev environement with its own vendor, include its autoload |
| 4 | -if(file_exists(__DIR__ . '/vendor')) |
|
| 4 | +if(file_exists(__DIR__ . '/vendor')) { |
|
| 5 | 5 | require_once __DIR__ . '/vendor/autoload.php'; |
| 6 | +} |
|
| 6 | 7 | // if library is in vendor of another project, include the global autolaod |
| 7 | -else |
|
| 8 | +else { |
|
| 8 | 9 | require_once __DIR__ . '/../../autoload.php'; |
| 10 | +} |
|
@@ -42,7 +42,7 @@ |
||
| 42 | 42 | { |
| 43 | 43 | $callback = null; |
| 44 | 44 | if ($valueProvider instanceof ValueProvider) { |
| 45 | - $callback = function (Point $p) use ($valueProvider) { |
|
| 45 | + $callback = function(Point $p) use ($valueProvider) { |
|
| 46 | 46 | return $valueProvider->get($p); |
| 47 | 47 | }; |
| 48 | 48 | } elseif (is_callable($valueProvider)) { |
@@ -234,7 +234,7 @@ discard block |
||
| 234 | 234 | throw new \InvalidArgumentException('UpTo argument must be Point or integer'); |
| 235 | 235 | } |
| 236 | 236 | |
| 237 | - for ($x = $this->getX(); $x <= $upTo; $x+=$step) { |
|
| 237 | + for ($x = $this->getX(); $x <= $upTo; $x += $step) { |
|
| 238 | 238 | yield $x; |
| 239 | 239 | } |
| 240 | 240 | } |
@@ -253,7 +253,7 @@ discard block |
||
| 253 | 253 | throw new \InvalidArgumentException('UpTo argument must be Point or integer'); |
| 254 | 254 | } |
| 255 | 255 | |
| 256 | - for ($y = $this->getY(); $y <= $upTo; $y+=$step) { |
|
| 256 | + for ($y = $this->getY(); $y <= $upTo; $y += $step) { |
|
| 257 | 257 | yield $y; |
| 258 | 258 | } |
| 259 | 259 | } |
@@ -26,7 +26,7 @@ |
||
| 26 | 26 | */ |
| 27 | 27 | public function current() |
| 28 | 28 | { |
| 29 | - return new Line($this->points[$this->index], $this->points[$this->index+1]); |
|
| 29 | + return new Line($this->points[$this->index], $this->points[$this->index + 1]); |
|
| 30 | 30 | } |
| 31 | 31 | |
| 32 | 32 | public function next() |
@@ -53,7 +53,7 @@ discard block |
||
| 53 | 53 | */ |
| 54 | 54 | public function getAllX() |
| 55 | 55 | { |
| 56 | - return array_map(function (Point $p) { |
|
| 56 | + return array_map(function(Point $p) { |
|
| 57 | 57 | return $p->getX(); |
| 58 | 58 | }, $this->points); |
| 59 | 59 | } |
@@ -63,7 +63,7 @@ discard block |
||
| 63 | 63 | */ |
| 64 | 64 | public function getAllY() |
| 65 | 65 | { |
| 66 | - return array_map(function (Point $p) { |
|
| 66 | + return array_map(function(Point $p) { |
|
| 67 | 67 | return $p->getY(); |
| 68 | 68 | }, $this->points); |
| 69 | 69 | } |
@@ -103,7 +103,7 @@ discard block |
||
| 103 | 103 | public function lastLine() |
| 104 | 104 | { |
| 105 | 105 | $count = count($this->points); |
| 106 | - return new Line($this->points[$count-2], $this->points[$count-1]); |
|
| 106 | + return new Line($this->points[$count - 2], $this->points[$count - 1]); |
|
| 107 | 107 | } |
| 108 | 108 | |
| 109 | 109 | /** |
@@ -52,7 +52,7 @@ |
||
| 52 | 52 | |
| 53 | 53 | if ($this->path->firstPoint()->getX() > $x) { |
| 54 | 54 | $containingLine = $this->path->firstLine(); |
| 55 | - } else { |
|
| 55 | + } else { |
|
| 56 | 56 | $containingLine = $this->path->lastLine(); |
| 57 | 57 | } |
| 58 | 58 | } |
@@ -52,7 +52,7 @@ |
||
| 52 | 52 | |
| 53 | 53 | if ($this->path->firstPoint()->getX() > $x) { |
| 54 | 54 | $containingLine = $this->path->firstLine(); |
| 55 | - } else { |
|
| 55 | + } else { |
|
| 56 | 56 | $containingLine = $this->path->lastLine(); |
| 57 | 57 | } |
| 58 | 58 | } |
@@ -10,11 +10,11 @@ discard block |
||
| 10 | 10 | public function count_provider() |
| 11 | 11 | { |
| 12 | 12 | return [ |
| 13 | - [new Point(1,1), new Point(1, 1), 1], |
|
| 14 | - [new Point(1,1), new Point(2, 2), 4], |
|
| 15 | - [new Point(1,1), new Point(3, 3), 9], |
|
| 13 | + [new Point(1, 1), new Point(1, 1), 1], |
|
| 14 | + [new Point(1, 1), new Point(2, 2), 4], |
|
| 15 | + [new Point(1, 1), new Point(3, 3), 9], |
|
| 16 | 16 | |
| 17 | - [new Point(1,1), new Point(4, 3), 12], |
|
| 17 | + [new Point(1, 1), new Point(4, 3), 12], |
|
| 18 | 18 | ]; |
| 19 | 19 | } |
| 20 | 20 | |
@@ -33,15 +33,15 @@ discard block |
||
| 33 | 33 | public function point_belongs_to_rectangular_provider() |
| 34 | 34 | { |
| 35 | 35 | return [ |
| 36 | - [new Point(1,1), new Point(4, 3), new Point(1,1), true], |
|
| 37 | - [new Point(1,1), new Point(4, 3), new Point(2,2), true], |
|
| 38 | - [new Point(1,1), new Point(4, 3), new Point(3,3), true], |
|
| 39 | - [new Point(1,1), new Point(4, 3), new Point(4,3), true], |
|
| 40 | - |
|
| 41 | - [new Point(1,1), new Point(4, 3), new Point(0,0), false], |
|
| 42 | - [new Point(1,1), new Point(4, 3), new Point(0,4), false], |
|
| 43 | - [new Point(1,1), new Point(4, 3), new Point(4,4), false], |
|
| 44 | - [new Point(1,1), new Point(4, 3), new Point(4,0), false], |
|
| 36 | + [new Point(1, 1), new Point(4, 3), new Point(1, 1), true], |
|
| 37 | + [new Point(1, 1), new Point(4, 3), new Point(2, 2), true], |
|
| 38 | + [new Point(1, 1), new Point(4, 3), new Point(3, 3), true], |
|
| 39 | + [new Point(1, 1), new Point(4, 3), new Point(4, 3), true], |
|
| 40 | + |
|
| 41 | + [new Point(1, 1), new Point(4, 3), new Point(0, 0), false], |
|
| 42 | + [new Point(1, 1), new Point(4, 3), new Point(0, 4), false], |
|
| 43 | + [new Point(1, 1), new Point(4, 3), new Point(4, 4), false], |
|
| 44 | + [new Point(1, 1), new Point(4, 3), new Point(4, 0), false], |
|
| 45 | 45 | ]; |
| 46 | 46 | } |
| 47 | 47 | |
@@ -11,11 +11,11 @@ discard block |
||
| 11 | 11 | { |
| 12 | 12 | public function test_draw() |
| 13 | 13 | { |
| 14 | - $circularProducer = new CircularCenterRadius(new Point(15,15), 10, true); |
|
| 14 | + $circularProducer = new CircularCenterRadius(new Point(15, 15), 10, true); |
|
| 15 | 15 | $circle = $circularProducer->produce(); |
| 16 | 16 | |
| 17 | 17 | $circle->smallestRectangularEnvelope(); |
| 18 | - $rectangularProducer = new RectangularFromTwoPoints(new Point(0,0), new Point(30, 30)); |
|
| 18 | + $rectangularProducer = new RectangularFromTwoPoints(new Point(0, 0), new Point(30, 30)); |
|
| 19 | 19 | $rect = $rectangularProducer->produce(); |
| 20 | 20 | |
| 21 | 21 | if (false) { |
@@ -47,18 +47,18 @@ discard block |
||
| 47 | 47 | |
| 48 | 48 | print "\n\n\n\n"; |
| 49 | 49 | $firstLine = true; |
| 50 | - for ($y=0, $yMax = count($arr); $y<$yMax; $y++) { |
|
| 50 | + for ($y = 0, $yMax = count($arr); $y < $yMax; $y++) { |
|
| 51 | 51 | $row = $arr[$y]; |
| 52 | 52 | if ($firstLine) { |
| 53 | 53 | $firstLine = false; |
| 54 | 54 | print 'y '; |
| 55 | - for ($x=0, $xMax = count($row); $x<$xMax; $x++) { |
|
| 55 | + for ($x = 0, $xMax = count($row); $x < $xMax; $x++) { |
|
| 56 | 56 | print $x % 10; |
| 57 | 57 | } |
| 58 | 58 | print " x \n"; |
| 59 | 59 | } |
| 60 | 60 | print str_pad($y, 3); |
| 61 | - for ($x=0, $xMax = count($row); $x<$xMax; $x++) { |
|
| 61 | + for ($x = 0, $xMax = count($row); $x < $xMax; $x++) { |
|
| 62 | 62 | print $row[$x]; |
| 63 | 63 | } |
| 64 | 64 | print "\n"; |
@@ -10,7 +10,7 @@ discard block |
||
| 10 | 10 | public function test_index_data_with_points() |
| 11 | 11 | { |
| 12 | 12 | $set = new PointSet(); |
| 13 | - $set->attach($p11 = new Point(1,1), $v11 = 'v11'); |
|
| 13 | + $set->attach($p11 = new Point(1, 1), $v11 = 'v11'); |
|
| 14 | 14 | |
| 15 | 15 | static::assertTrue($set->contains($p11)); |
| 16 | 16 | static::assertEquals($set[$p11], $v11); |
@@ -18,8 +18,8 @@ discard block |
||
| 18 | 18 | |
| 19 | 19 | public function test_union() |
| 20 | 20 | { |
| 21 | - $a = new PointSet([new Point(1,1), new Point(2,2), new Point(3,3)]); |
|
| 22 | - $b = new PointSet([new Point(3,1), new Point(2,2), new Point(1,3)]); |
|
| 21 | + $a = new PointSet([new Point(1, 1), new Point(2, 2), new Point(3, 3)]); |
|
| 22 | + $b = new PointSet([new Point(3, 1), new Point(2, 2), new Point(1, 3)]); |
|
| 23 | 23 | $r = $a->union($b); |
| 24 | 24 | |
| 25 | 25 | static::assertEquals(3, $a->count()); |
@@ -38,8 +38,8 @@ discard block |
||
| 38 | 38 | |
| 39 | 39 | public function test_intersect() |
| 40 | 40 | { |
| 41 | - $a = new PointSet([new Point(1,1), new Point(2,2), new Point(3,3)]); |
|
| 42 | - $b = new PointSet([new Point(3,1), new Point(2,2), new Point(1,3)]); |
|
| 41 | + $a = new PointSet([new Point(1, 1), new Point(2, 2), new Point(3, 3)]); |
|
| 42 | + $b = new PointSet([new Point(3, 1), new Point(2, 2), new Point(1, 3)]); |
|
| 43 | 43 | $r = $a->intersect($b); |
| 44 | 44 | |
| 45 | 45 | static::assertEquals(3, $a->count()); |
@@ -48,13 +48,13 @@ discard block |
||
| 48 | 48 | static::assertNotSame($r, $a); |
| 49 | 49 | static::assertNotSame($r, $b); |
| 50 | 50 | |
| 51 | - static::assertTrue($r->contains(new Point(2,2))); |
|
| 51 | + static::assertTrue($r->contains(new Point(2, 2))); |
|
| 52 | 52 | } |
| 53 | 53 | |
| 54 | 54 | public function test_diff() |
| 55 | 55 | { |
| 56 | - $a = new PointSet([new Point(1,1), new Point(2,2), new Point(3,3)]); |
|
| 57 | - $b = new PointSet([new Point(3,1), new Point(2,2), new Point(1,3)]); |
|
| 56 | + $a = new PointSet([new Point(1, 1), new Point(2, 2), new Point(3, 3)]); |
|
| 57 | + $b = new PointSet([new Point(3, 1), new Point(2, 2), new Point(1, 3)]); |
|
| 58 | 58 | $r = $a->diff($b); |
| 59 | 59 | |
| 60 | 60 | static::assertEquals(3, $a->count()); |
@@ -63,7 +63,7 @@ discard block |
||
| 63 | 63 | static::assertNotSame($r, $a); |
| 64 | 64 | static::assertNotSame($r, $b); |
| 65 | 65 | |
| 66 | - static::assertTrue($r->contains(new Point(1,1))); |
|
| 67 | - static::assertTrue($r->contains(new Point(3,3))); |
|
| 66 | + static::assertTrue($r->contains(new Point(1, 1))); |
|
| 67 | + static::assertTrue($r->contains(new Point(3, 3))); |
|
| 68 | 68 | } |
| 69 | 69 | } |