Skip to content

Commit 6b9f6e9

Browse files
author
Martin Brecht-Precht
committed
Updated composer.json.
Updated readme. Code cleanup QrCodePathFinder class.
1 parent c33ccf1 commit 6b9f6e9

File tree

3 files changed

+39
-39
lines changed

3 files changed

+39
-39
lines changed

QrRender/PathFinder/QrCodePathFinder.php

Lines changed: 37 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -66,15 +66,15 @@ private function findPaths()
6666
}
6767

6868
/**
69-
* @param int $x
70-
* @param int $y
69+
* @param int $xPosition
70+
* @param int $yPosition
7171
* @return bool
7272
*/
73-
private function isCorner($x, $y)
73+
private function isCorner($xPosition, $yPosition)
7474
{
75-
$currentPoint = $this->qrCode->getRow($y)->getPoint($x);
76-
$neighbourPoint = $this->qrCode->getRow($y - 1)->getPoint($x - 1);
77-
if ($neighbourPoint == $this->qrCode->getRow($y)->getPoint($x - 1) && $neighbourPoint == $this->qrCode->getRow($y - 1)->getPoint($x)) {
75+
$currentPoint = $this->qrCode->getRow($yPosition)->getPoint($xPosition);
76+
$neighbourPoint = $this->qrCode->getRow($yPosition - 1)->getPoint($xPosition - 1);
77+
if ($neighbourPoint == $this->qrCode->getRow($yPosition)->getPoint($xPosition - 1) && $neighbourPoint == $this->qrCode->getRow($yPosition - 1)->getPoint($xPosition)) {
7878
if ($neighbourPoint != $currentPoint) {
7979
return true;
8080
}
@@ -83,90 +83,90 @@ private function isCorner($x, $y)
8383
}
8484

8585
/**
86-
* @param int $startX
87-
* @param int $startY
86+
* @param int $startXPosition
87+
* @param int $startYPosition
8888
* @param bool $active
8989
* @return array
9090
*/
91-
private function traceComposite($startX, $startY, $active)
91+
private function traceComposite($startXPosition, $startYPosition, $active)
9292
{
9393

94-
$x = $startX;
95-
$y = $startY;
94+
$xPosition = $startXPosition;
95+
$yPosition = $startYPosition;
9696
$switched = !$active;
9797

9898
$direction = self::DIRECTION_RIGHT;
9999

100100
$path = new Path();
101-
$path->addPoint($this->getPoint($x, $y));
101+
$path->addPoint($this->getPoint($xPosition, $yPosition));
102102

103103
do {
104104
switch ($direction) {
105105
case self::DIRECTION_RIGHT:
106-
$current = $this->qrCode->getRow($y)->getPoint($x);
107-
$other = $this->qrCode->getRow($y - 1)->getPoint($x);
106+
$current = $this->qrCode->getRow($yPosition)->getPoint($xPosition);
107+
$other = $this->qrCode->getRow($yPosition - 1)->getPoint($xPosition);
108108
if ($current != $other) {
109109
$switched = $other;
110-
$x++;
110+
$xPosition++;
111111
} else {
112-
$path->addPoint($this->getPoint($x, $y));
112+
$path->addPoint($this->getPoint($xPosition, $yPosition));
113113
$direction = ($switched == $other) ? self::DIRECTION_DOWN : self::DIRECTION_UP;
114114
}
115115
break;
116116
case self::DIRECTION_UP:
117-
$current = $this->qrCode->getRow($y - 1)->getPoint($x);
118-
$other = $this->qrCode->getRow($y - 1)->getPoint($x - 1);
117+
$current = $this->qrCode->getRow($yPosition - 1)->getPoint($xPosition);
118+
$other = $this->qrCode->getRow($yPosition - 1)->getPoint($xPosition - 1);
119119
if ($current != $other) {
120120
$switched = $other;
121-
$y--;
121+
$yPosition--;
122122
} else {
123-
$path->addPoint($this->getPoint($x, $y));
123+
$path->addPoint($this->getPoint($xPosition, $yPosition));
124124
$direction = ($switched == $other) ? self::DIRECTION_RIGHT : self::DIRECTION_LEFT;
125-
if ($direction == self::DIRECTION_RIGHT && $this->isCorner($x, $y)) {
126-
$this->visited[$y][$x] = true;
125+
if ($direction == self::DIRECTION_RIGHT && $this->isCorner($xPosition, $yPosition)) {
126+
$this->visited[$yPosition][$xPosition] = true;
127127
}
128128
}
129129
break;
130130
case self::DIRECTION_LEFT:
131-
$current = $this->qrCode->getRow($y - 1)->getPoint($x - 1);
132-
$other = $this->qrCode->getRow($y)->getPoint($x - 1);
131+
$current = $this->qrCode->getRow($yPosition - 1)->getPoint($xPosition - 1);
132+
$other = $this->qrCode->getRow($yPosition)->getPoint($xPosition - 1);
133133
if ($current != $other) {
134134
$switched = $other;
135-
$x--;
135+
$xPosition--;
136136
} else {
137-
$path->addPoint($this->getPoint($x, $y));
137+
$path->addPoint($this->getPoint($xPosition, $yPosition));
138138
$direction = ($switched == $other) ? self::DIRECTION_UP : self::DIRECTION_DOWN;
139-
if ($direction == self::DIRECTION_DOWN && $this->isCorner($x, $y)) {
140-
$this->visited[$y][$x] = true;
139+
if ($direction == self::DIRECTION_DOWN && $this->isCorner($xPosition, $yPosition)) {
140+
$this->visited[$yPosition][$xPosition] = true;
141141
}
142142
}
143143
break;
144144
case self::DIRECTION_DOWN:
145-
$current = $this->qrCode->getRow($y)->getPoint($x - 1);
146-
$other = $this->qrCode->getRow($y)->getPoint($x);
145+
$current = $this->qrCode->getRow($yPosition)->getPoint($xPosition - 1);
146+
$other = $this->qrCode->getRow($yPosition)->getPoint($xPosition);
147147
if ($current != $other) {
148148
$switched = $other;
149-
$y++;
149+
$yPosition++;
150150
} else {
151-
$path->addPoint($this->getPoint($x, $y));
151+
$path->addPoint($this->getPoint($xPosition, $yPosition));
152152
$direction = ($switched == $other) ? self::DIRECTION_LEFT : self::DIRECTION_RIGHT;
153153
}
154154
break;
155155
}
156-
} while (!($x == $startX && $y == $startY));
156+
} while (!($xPosition == $startXPosition && $yPosition == $startYPosition));
157157

158158
return $path;
159159

160160
}
161161

162162
/**
163-
* @param int $x
164-
* @param int $y
163+
* @param int $xPosition
164+
* @param int $yPosition
165165
* @return PathPoint
166166
*/
167-
private function getPoint($x, $y)
167+
private function getPoint($xPosition, $yPosition)
168168
{
169-
return new PathPoint($x - 1, $y - 1);
169+
return new PathPoint($xPosition - 1, $yPosition - 1);
170170
}
171171

172172
}

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
[![Total Downloads](https://poser.pugx.org/markenwerk/qr-code-suite/downloads)](https://packagist.org/packages/markenwerk/qr-code-suite)
77
[![License](https://poser.pugx.org/markenwerk/qr-code-suite/license)](https://packagist.org/packages/markenwerk/qr-code-suite)
88

9-
A collection of classes to provide second factor authentication (Yubico OTP, TOTP, HOTP, GoogleAuthenticator) server-side.
9+
A collection of classes to QR enccode strings and render them as PNG, TIFF and vectorized EPS.
1010

1111
## Installation
1212

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "markenwerk/qr-code-suite",
33
"type": "library",
4-
"description": "A collection of classes to ",
4+
"description": "A collection of classes to QR enccode strings and render them as PNG, TIFF and vectorized EPS.",
55
"keywords": [
66
"qr code",
77
"qr encode"

0 commit comments

Comments
 (0)