PluginProbe ʕ •ᴥ•ʔ
Booking for Appointments and Events Calendar – Amelia / 2.4.6
Booking for Appointments and Events Calendar – Amelia v2.4.6
2.4.7 2.4.6 2.4.5 2.4.4 2.4.3 2.4.2 2.4.1 2.4 trunk 1.2.1 1.2.10 1.2.11 1.2.12 1.2.13 1.2.14 1.2.15 1.2.16 1.2.17 1.2.18 1.2.19 1.2.2 1.2.20 1.2.21 1.2.22 1.2.23 1.2.24 1.2.25 1.2.26 1.2.27 1.2.28 1.2.29 1.2.3 1.2.30 1.2.31 1.2.32 1.2.33 1.2.34 1.2.35 1.2.36 1.2.37 1.2.38 1.2.4 1.2.5 1.2.6 1.2.7 1.2.8 1.2.9 2.0 2.0.1 2.0.2 2.1 2.1.1 2.1.2 2.1.3 2.2 2.2.1 2.3
ameliabooking / vendor / bacon / bacon-qr-code / src / Renderer / Module / EdgeIterator / Edge.php
ameliabooking / vendor / bacon / bacon-qr-code / src / Renderer / Module / EdgeIterator Last commit date
Edge.php 9 months ago EdgeIterator.php 9 months ago
Edge.php
101 lines
1 <?php
2 declare(strict_types = 1);
3
4 namespace BaconQrCode\Renderer\Module\EdgeIterator;
5
6 final class Edge
7 {
8 /**
9 * @var bool
10 */
11 private $positive;
12
13 /**
14 * @var array<int[]>
15 */
16 private $points = [];
17
18 /**
19 * @var array<int[]>|null
20 */
21 private $simplifiedPoints;
22
23 /**
24 * @var int
25 */
26 private $minX = PHP_INT_MAX;
27
28 /**
29 * @var int
30 */
31 private $minY = PHP_INT_MAX;
32
33 /**
34 * @var int
35 */
36 private $maxX = -1;
37
38 /**
39 * @var int
40 */
41 private $maxY = -1;
42
43 public function __construct(bool $positive)
44 {
45 $this->positive = $positive;
46 }
47
48 public function addPoint(int $x, int $y) : void
49 {
50 $this->points[] = [$x, $y];
51 $this->minX = min($this->minX, $x);
52 $this->minY = min($this->minY, $y);
53 $this->maxX = max($this->maxX, $x);
54 $this->maxY = max($this->maxY, $y);
55 }
56
57 public function isPositive() : bool
58 {
59 return $this->positive;
60 }
61
62 /**
63 * @return array<int[]>
64 */
65 public function getPoints() : array
66 {
67 return $this->points;
68 }
69
70 public function getMaxX() : int
71 {
72 return $this->maxX;
73 }
74
75 public function getSimplifiedPoints() : array
76 {
77 if (null !== $this->simplifiedPoints) {
78 return $this->simplifiedPoints;
79 }
80
81 $points = [];
82 $length = count($this->points);
83
84 for ($i = 0; $i < $length; ++$i) {
85 $previousPoint = $this->points[(0 === $i ? $length : $i) - 1];
86 $nextPoint = $this->points[($length - 1 === $i ? -1 : $i) + 1];
87 $currentPoint = $this->points[$i];
88
89 if (($previousPoint[0] === $currentPoint[0] && $currentPoint[0] === $nextPoint[0])
90 || ($previousPoint[1] === $currentPoint[1] && $currentPoint[1] === $nextPoint[1])
91 ) {
92 continue;
93 }
94
95 $points[] = $currentPoint;
96 }
97
98 return $this->simplifiedPoints = $points;
99 }
100 }
101