PluginProbe ʕ •ᴥ•ʔ
WP 2FA – Two-factor authentication for WordPress / 4.0.0
WP 2FA – Two-factor authentication for WordPress v4.0.0
4.0.0 1.7.1 2.0.0 2.0.1 2.1.0 2.2.0 2.2.1 2.3.0 2.4.0 2.4.1 2.4.2 2.5.0 2.6.0 2.6.1 2.6.2 2.6.3 2.6.4 2.7.0 2.8.0 2.9.0 2.9.1 2.9.2 2.9.3 3.0.0 3.0.1 3.1.0 3.1.1 3.1.1.2 trunk 1.2.0 1.3.0 1.4.0 1.4.1 1.4.2 1.5.0 1.5.1 1.5.2 1.6.0 1.6.1 1.6.2 1.7.0
wp-2fa / includes / classes / bacon / bacon-qr-code / src / Renderer / Module / EdgeIterator / Edge.php
wp-2fa / includes / classes / bacon / bacon-qr-code / src / Renderer / Module / EdgeIterator Last commit date
Edge.php 1 week ago EdgeIterator.php 1 week ago index.php 1 week ago
Edge.php
82 lines
1 <?php
2
3 declare (strict_types=1);
4 namespace WP2FA_Vendor\BaconQrCode\Renderer\Module\EdgeIterator;
5
6 final class Edge
7 {
8 /**
9 * @var bool
10 */
11 private $positive;
12 /**
13 * @var array<int[]>
14 */
15 private $points = [];
16 /**
17 * @var array<int[]>|null
18 */
19 private $simplifiedPoints;
20 /**
21 * @var int
22 */
23 private $minX = \PHP_INT_MAX;
24 /**
25 * @var int
26 */
27 private $minY = \PHP_INT_MAX;
28 /**
29 * @var int
30 */
31 private $maxX = -1;
32 /**
33 * @var int
34 */
35 private $maxY = -1;
36 public function __construct(bool $positive)
37 {
38 $this->positive = $positive;
39 }
40 public function addPoint(int $x, int $y) : void
41 {
42 $this->points[] = [$x, $y];
43 $this->minX = \min($this->minX, $x);
44 $this->minY = \min($this->minY, $y);
45 $this->maxX = \max($this->maxX, $x);
46 $this->maxY = \max($this->maxY, $y);
47 }
48 public function isPositive() : bool
49 {
50 return $this->positive;
51 }
52 /**
53 * @return array<int[]>
54 */
55 public function getPoints() : array
56 {
57 return $this->points;
58 }
59 public function getMaxX() : int
60 {
61 return $this->maxX;
62 }
63 public function getSimplifiedPoints() : array
64 {
65 if (null !== $this->simplifiedPoints) {
66 return $this->simplifiedPoints;
67 }
68 $points = [];
69 $length = \count($this->points);
70 for ($i = 0; $i < $length; ++$i) {
71 $previousPoint = $this->points[(0 === $i ? $length : $i) - 1];
72 $nextPoint = $this->points[($length - 1 === $i ? -1 : $i) + 1];
73 $currentPoint = $this->points[$i];
74 if ($previousPoint[0] === $currentPoint[0] && $currentPoint[0] === $nextPoint[0] || $previousPoint[1] === $currentPoint[1] && $currentPoint[1] === $nextPoint[1]) {
75 continue;
76 }
77 $points[] = $currentPoint;
78 }
79 return $this->simplifiedPoints = $points;
80 }
81 }
82