Skip to content

Commit b08ca7b

Browse files
author
Martin Brecht-Precht
committed
Changed the root namespace and the vendor prefix.
1 parent 7256b58 commit b08ca7b

16 files changed

+150
-129
lines changed

LICENSE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
The MIT License (MIT)
22

3-
Copyright (c) 2016 Martin Brecht-Precht, Markenwerk GmbH
3+
Copyright (c) 2016 Martin Brecht-Precht, Chroma Experience GmbH
44

55
Permission is hereby granted, free of charge, to any person obtaining a copy
66
of this software and associated documentation files (the "Software"), to deal
Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,15 @@
11
<?php
22

3-
namespace QrCodeSuite\QrEncode\Exception;
3+
namespace ChromaX\QrCodeSuite\QrEncode\Exception;
4+
5+
use Exception;
46

57
/**
68
* Class QrEncoderException
79
*
8-
* @package QrCodeSuite\QrEncode\Exception
10+
* @package ChromaX\QrCodeSuite\QrEncode\Exception
911
*/
10-
class QrEncoderException extends \Exception
12+
class QrEncoderException extends Exception
1113
{
1214

1315
}

QrEncode/QrCode/QrCode.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
<?php
22

3-
namespace QrCodeSuite\QrEncode\QrCode;
3+
namespace ChromaX\QrCodeSuite\QrEncode\QrCode;
44

55
/**
66
* Class QrCode
77
*
8-
* @package QrCodeSuite\QrEncode
8+
* @package ChromaX\QrCodeSuite\QrEncode
99
*/
1010
class QrCode
1111
{

QrEncode/QrCode/QrCodePoint.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
<?php
22

3-
namespace QrCodeSuite\QrEncode\QrCode;
3+
namespace ChromaX\QrCodeSuite\QrEncode\QrCode;
44

55
/**
66
* Class QrCodePoint
77
*
8-
* @package QrCodeSuite\QrEncode
8+
* @package ChromaX\QrCodeSuite\QrEncode
99
*/
1010
class QrCodePoint
1111
{

QrEncode/QrCode/QrCodePointRow.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
<?php
22

3-
namespace QrCodeSuite\QrEncode\QrCode;
3+
namespace ChromaX\QrCodeSuite\QrEncode\QrCode;
44

55
/**
66
* Class QrCodePointRow
77
*
8-
* @package QrCodeSuite\QrEncode
8+
* @package ChromaX\QrCodeSuite\QrEncode
99
*/
1010
class QrCodePointRow
1111
{

QrEncode/QrEncoder.php

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
11
<?php
22

3-
namespace QrCodeSuite\QrEncode;
3+
namespace ChromaX\QrCodeSuite\QrEncode;
44

5-
use QrCodeSuite\QrEncode\Exception\QrEncoderException;
6-
use QrCodeSuite\QrEncode\QrCode\QrCode;
7-
use QrCodeSuite\QrEncode\QrCode\QrCodePointRow;
8-
use QrCodeSuite\QrEncode\QrCode\QrCodePoint;
5+
use ChromaX\QrCodeSuite\QrEncode\Exception\QrEncoderException;
6+
use ChromaX\QrCodeSuite\QrEncode\QrCode\QrCode;
7+
use ChromaX\QrCodeSuite\QrEncode\QrCode\QrCodePointRow;
8+
use ChromaX\QrCodeSuite\QrEncode\QrCode\QrCodePoint;
99

1010
/**
1111
* Class QrEncoder
1212
*
13-
* @package QrCodeSuite\QrEncode
13+
* @package ChromaX\QrCodeSuite\QrEncode
1414
*/
1515
class QrEncoder
1616
{
@@ -85,7 +85,7 @@ public function encodeQrCode($contents)
8585
{
8686
$chars = str_split($contents);
8787
foreach ($chars as $char) {
88-
if (0 == ord($char)) {
88+
if (0 === ord($char)) {
8989
throw new QrEncoderException('Encoding null character failed');
9090
}
9191
}

QrRender/Base/QrCodeRendererInterface.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
<?php
22

3-
namespace QrCodeSuite\QrRender\Base;
3+
namespace ChromaX\QrCodeSuite\QrRender\Base;
44

5-
use QrCodeSuite\QrEncode\QrCode\QrCode;
5+
use ChromaX\QrCodeSuite\QrEncode\QrCode\QrCode;
66

77
/**
88
* Interface QrCodeRendererInterface
99
*
10-
* @package QrCodeSuite\QrRender\Base
10+
* @package ChromaX\QrCodeSuite\QrRender\Base
1111
*/
1212
interface QrCodeRendererInterface
1313
{

QrRender/Exception/IoException.php

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,15 @@
11
<?php
22

3-
namespace QrCodeSuite\QrRender\Exception;
3+
namespace ChromaX\QrCodeSuite\QrRender\Exception;
4+
5+
use Exception;
46

57
/**
68
* Class IoException
79
*
8-
* @package QrCodeSuite\QrRender\Exception
10+
* @package ChromaX\QrCodeSuite\QrRender\Exception
911
*/
10-
class IoException extends \Exception
12+
class IoException extends Exception
1113
{
1214

1315
}

QrRender/PathFinder/Path.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
<?php
22

3-
namespace QrCodeSuite\QrRender\PathFinder;
3+
namespace ChromaX\QrCodeSuite\QrRender\PathFinder;
44

55
/**
66
* Class Path
77
*
8-
* @package QrCodeSuite\QrRender\PathFinder
8+
* @package ChromaX\QrCodeSuite\QrRender\PathFinder
99
*/
1010
class Path
1111
{

QrRender/PathFinder/PathPoint.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
<?php
22

3-
namespace QrCodeSuite\QrRender\PathFinder;
3+
namespace ChromaX\QrCodeSuite\QrRender\PathFinder;
44

55
/**
66
* Class PathPoint
77
*
8-
* @package QrCodeSuite\QrRender\PathFinder
8+
* @package ChromaX\QrCodeSuite\QrRender\PathFinder
99
*/
1010
class PathPoint
1111
{

QrRender/PathFinder/QrCodePathFinder.php

Lines changed: 32 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
<?php
22

3-
namespace QrCodeSuite\QrRender\PathFinder;
3+
namespace ChromaX\QrCodeSuite\QrRender\PathFinder;
44

5-
use QrCodeSuite\QrEncode\QrCode\QrCode;
5+
use ChromaX\QrCodeSuite\QrEncode\QrCode\QrCode;
66

77
/**
88
* Class QrCodePathFinder
99
*
10-
* @package QrCodeSuite\QrRender\PathFinder
10+
* @package ChromaX\QrCodeSuite\QrRender\PathFinder
1111
*/
1212
class QrCodePathFinder
1313
{
@@ -53,12 +53,14 @@ private function findPaths()
5353
{
5454
for ($y = 1; $y <= $this->qrCode->getHeight(); $y++) {
5555
$qrCodePointRow = $this->qrCode->getRow($y);
56-
for ($x = 1; $x <= $this->qrCode->getWidth(); $x++) {
57-
if (!isset($this->visited[$y][$x])) {
58-
$qrCodePoint = $qrCodePointRow->getPoint($x);
59-
if ($this->isCorner($x, $y)) {
60-
$this->paths[] = $this->traceComposite($x, $y, $qrCodePoint->isActive());
61-
$this->visited[$y][$x] = true;
56+
if ($qrCodePointRow !== null) {
57+
for ($x = 1; $x <= $this->qrCode->getWidth(); $x++) {
58+
if (!isset($this->visited[$y][$x])) {
59+
$qrCodePoint = $qrCodePointRow->getPoint($x);
60+
if ($qrCodePoint !== null && $this->isCorner($x, $y)) {
61+
$this->paths[] = $this->traceComposite($x, $y, $qrCodePoint->isActive());
62+
$this->visited[$y][$x] = true;
63+
}
6264
}
6365
}
6466
}
@@ -72,10 +74,15 @@ private function findPaths()
7274
*/
7375
private function isCorner($xPosition, $yPosition)
7476
{
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)) {
78-
if ($neighbourPoint != $currentPoint) {
77+
$qrCodePointRow = $this->qrCode->getRow($yPosition);
78+
$previouseQrCodePointRow = $this->qrCode->getRow($yPosition - 1);
79+
if ($qrCodePointRow === null || $previouseQrCodePointRow === null) {
80+
return false;
81+
}
82+
$currentPoint = $qrCodePointRow->getPoint($xPosition);
83+
$neighbourPoint = $previouseQrCodePointRow->getPoint($xPosition - 1);
84+
if ($neighbourPoint === $qrCodePointRow->getPoint($xPosition - 1) && $neighbourPoint === $previouseQrCodePointRow->getPoint($xPosition)) {
85+
if ($neighbourPoint !== $currentPoint) {
7986
return true;
8087
}
8188
}
@@ -86,7 +93,7 @@ private function isCorner($xPosition, $yPosition)
8693
* @param int $startXPosition
8794
* @param int $startYPosition
8895
* @param bool $active
89-
* @return array
96+
* @return Path
9097
*/
9198
private function traceComposite($startXPosition, $startYPosition, $active)
9299
{
@@ -105,55 +112,55 @@ private function traceComposite($startXPosition, $startYPosition, $active)
105112
case self::DIRECTION_RIGHT:
106113
$current = $this->qrCode->getRow($yPosition)->getPoint($xPosition);
107114
$other = $this->qrCode->getRow($yPosition - 1)->getPoint($xPosition);
108-
if ($current != $other) {
115+
if ($current !== $other) {
109116
$switched = $other;
110117
$xPosition++;
111118
} else {
112119
$path->addPoint($this->getPoint($xPosition, $yPosition));
113-
$direction = ($switched == $other) ? self::DIRECTION_DOWN : self::DIRECTION_UP;
120+
$direction = ($switched === $other) ? self::DIRECTION_DOWN : self::DIRECTION_UP;
114121
}
115122
break;
116123
case self::DIRECTION_UP:
117124
$current = $this->qrCode->getRow($yPosition - 1)->getPoint($xPosition);
118125
$other = $this->qrCode->getRow($yPosition - 1)->getPoint($xPosition - 1);
119-
if ($current != $other) {
126+
if ($current !== $other) {
120127
$switched = $other;
121128
$yPosition--;
122129
} else {
123130
$path->addPoint($this->getPoint($xPosition, $yPosition));
124-
$direction = ($switched == $other) ? self::DIRECTION_RIGHT : self::DIRECTION_LEFT;
125-
if ($direction == self::DIRECTION_RIGHT && $this->isCorner($xPosition, $yPosition)) {
131+
$direction = ($switched === $other) ? self::DIRECTION_RIGHT : self::DIRECTION_LEFT;
132+
if ($direction === self::DIRECTION_RIGHT && $this->isCorner($xPosition, $yPosition)) {
126133
$this->visited[$yPosition][$xPosition] = true;
127134
}
128135
}
129136
break;
130137
case self::DIRECTION_LEFT:
131138
$current = $this->qrCode->getRow($yPosition - 1)->getPoint($xPosition - 1);
132139
$other = $this->qrCode->getRow($yPosition)->getPoint($xPosition - 1);
133-
if ($current != $other) {
140+
if ($current !== $other) {
134141
$switched = $other;
135142
$xPosition--;
136143
} else {
137144
$path->addPoint($this->getPoint($xPosition, $yPosition));
138-
$direction = ($switched == $other) ? self::DIRECTION_UP : self::DIRECTION_DOWN;
139-
if ($direction == self::DIRECTION_DOWN && $this->isCorner($xPosition, $yPosition)) {
145+
$direction = ($switched === $other) ? self::DIRECTION_UP : self::DIRECTION_DOWN;
146+
if ($direction === self::DIRECTION_DOWN && $this->isCorner($xPosition, $yPosition)) {
140147
$this->visited[$yPosition][$xPosition] = true;
141148
}
142149
}
143150
break;
144151
case self::DIRECTION_DOWN:
145152
$current = $this->qrCode->getRow($yPosition)->getPoint($xPosition - 1);
146153
$other = $this->qrCode->getRow($yPosition)->getPoint($xPosition);
147-
if ($current != $other) {
154+
if ($current !== $other) {
148155
$switched = $other;
149156
$yPosition++;
150157
} else {
151158
$path->addPoint($this->getPoint($xPosition, $yPosition));
152-
$direction = ($switched == $other) ? self::DIRECTION_LEFT : self::DIRECTION_RIGHT;
159+
$direction = ($switched === $other) ? self::DIRECTION_LEFT : self::DIRECTION_RIGHT;
153160
}
154161
break;
155162
}
156-
} while (!($xPosition == $startXPosition && $yPosition == $startYPosition));
163+
} while (!($xPosition === $startXPosition && $yPosition === $startYPosition));
157164

158165
return $path;
159166

QrRender/QrCodeRendererEps.php

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
11
<?php
22

3-
namespace QrCodeSuite\QrRender;
3+
namespace ChromaX\QrCodeSuite\QrRender;
44

5-
use QrCodeSuite\QrEncode\QrCode\QrCode;
6-
use QrCodeSuite\QrRender\Exception\IoException;
7-
use QrCodeSuite\QrRender\PathFinder\PathPoint;
8-
use QrCodeSuite\QrRender\PathFinder\QrCodePathFinder;
5+
use ChromaX\QrCodeSuite\QrEncode\QrCode\QrCode;
6+
use ChromaX\QrCodeSuite\QrRender\Exception\IoException;
7+
use ChromaX\QrCodeSuite\QrRender\PathFinder\PathPoint;
8+
use ChromaX\QrCodeSuite\QrRender\PathFinder\QrCodePathFinder;
99

1010
/**
1111
* Class QrCodeRendererEps
1212
*
13-
* @package QrCodeSuite\QrRender
13+
* @package ChromaX\QrCodeSuite\QrRender
1414
*/
1515
class QrCodeRendererEps implements Base\QrCodeRendererInterface
1616
{
@@ -48,7 +48,7 @@ public function render(QrCode $qrCode, $filename)
4848
$epsSource[] = '%!PS-Adobe-2.0 EPSF-2.0';
4949
$epsSource[] = '%%BoundingBox: 0 0 ' . ceil($epsWidth) . ' ' . ceil($epsHeight) . '';
5050
$epsSource[] = '%%HiResBoundingBox: 0 0 ' . $epsWidth . ' ' . $epsHeight . '';
51-
$epsSource[] = '%%Creator: tk | markenwerk';
51+
$epsSource[] = '%%Creator: tk | chroma-x';
5252
$epsSource[] = '%%CreationDate: ' . time();
5353
$epsSource[] = '%%DocumentData: Clean7Bit';
5454
$epsSource[] = '%%LanguageLevel: 2';
@@ -61,7 +61,7 @@ public function render(QrCode $qrCode, $filename)
6161

6262
foreach ($paths as $path) {
6363
for ($i = 0; $i < $path->countPoints(); $i++) {
64-
if ($i == 0) {
64+
if ($i === 0) {
6565
$epsSource[] = $this->convertPoint($path->getFirstPoint()) . ' m';
6666
} else {
6767
$epsSource[] = $this->convertPoint($path->getPoint($i)) . ' l';

0 commit comments

Comments
 (0)