Skip to content

Commit 3045b98

Browse files
committed
resolve conflict
2 parents dd51bcd + 3cff5ac commit 3045b98

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

61 files changed

+4271
-4499
lines changed

composer.json

Lines changed: 31 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,34 @@
11
{
2-
"name": "khanamiryan/qrcode-detector-decoder",
3-
"type": "library",
4-
"description": "QR code decoder / reader",
5-
"keywords": ["qr", "zxing", "barcode"],
6-
"homepage": "https://github.com/khanamiryan/php-qrcode-detector-decoder",
7-
"license": "MIT",
8-
"authors": [{
9-
"name": "Ashot Khanamiryan",
10-
"email": "[email protected]",
11-
"homepage": "https://github.com/khanamiryan",
12-
"role": "Developer"
13-
}],
14-
"require": {
15-
"php": "^5.6|^7.0"
16-
},
17-
"require-dev": {
18-
"phpunit/phpunit": "^5.7"
19-
},
20-
"autoload": {
21-
"classmap": ["lib/"],
22-
"files": ["lib/common/customFunctions.php"]
2+
"name": "khanamiryan/qrcode-detector-decoder",
3+
"type": "library",
4+
"description": "QR code decoder / reader",
5+
"keywords": [
6+
"qr",
7+
"zxing",
8+
"barcode"
9+
],
10+
"homepage": "https://github.com/maestroprog/php-qrcode-detector-decoder",
11+
"license": "MIT",
12+
"authors": [
13+
{
14+
"name": "Ashot Khanamiryan",
15+
"email": "[email protected]",
16+
"homepage": "https://github.com/khanamiryan",
17+
"role": "Developer"
2318
}
19+
],
20+
"require": {
21+
"php": "^5.6|^7.0"
22+
},
23+
"require-dev": {
24+
"phpunit/phpunit": "^5.7"
25+
},
26+
"autoload": {
27+
"psr-4": {
28+
"Zxing\\": "lib/"
29+
},
30+
"files": [
31+
"lib/Common/customFunctions.php"
32+
]
33+
}
2434
}

lib/Binarizer.php

Lines changed: 20 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,7 @@
1515
* limitations under the License.
1616
*/
1717

18-
19-
namespace Zxing;
18+
namespace Zxing;
2019

2120
use Zxing\Common\BitArray;
2221
use Zxing\Common\BitMatrix;
@@ -29,15 +28,20 @@
2928
*
3029
* @author [email protected] (Daniel Switkin)
3130
*/
32-
abstract class Binarizer {
33-
31+
abstract class Binarizer
32+
{
3433
private $source;
3534

36-
protected function __construct($source) {
35+
protected function __construct($source)
36+
{
3737
$this->source = $source;
3838
}
3939

40-
public final function getLuminanceSource() {
40+
/**
41+
* @return LuminanceSource
42+
*/
43+
public final function getLuminanceSource()
44+
{
4145
return $this->source;
4246
}
4347

@@ -49,10 +53,11 @@ public final function getLuminanceSource() {
4953
* and passed in with each call for performance. However it is legal to keep more than one row
5054
* at a time if needed.
5155
*
52-
* @param y The row to fetch, which must be in [0, bitmap height)
56+
* @param y The row to fetch, which must be in [0, bitmap height)
5357
* @param row An optional preallocated array. If null or too small, it will be ignored.
5458
* If used, the Binarizer will call BitArray.clear(). Always use the returned object.
55-
* @return The array of bits for this row (true means black).
59+
*
60+
* @return array The array of bits for this row (true means black).
5661
* @throws NotFoundException if row can't be binarized
5762
*/
5863
public abstract function getBlackRow($y, $row);
@@ -63,7 +68,7 @@ public abstract function getBlackRow($y, $row);
6368
* may not apply sharpening. Therefore, a row from this matrix may not be identical to one
6469
* fetched using getBlackRow(), so don't mix and match between them.
6570
*
66-
* @return The 2D array of bits for the image (true means black).
71+
* @return BitMatrix The 2D array of bits for the image (true means black).
6772
* @throws NotFoundException if image can't be binarized to make a matrix
6873
*/
6974
public abstract function getBlackMatrix();
@@ -74,16 +79,18 @@ public abstract function getBlackMatrix();
7479
* of 1 bit data. See Effective Java for why we can't use Java's clone() method.
7580
*
7681
* @param source The LuminanceSource this Binarizer will operate on.
77-
* @return A new concrete Binarizer implementation object.
82+
*
83+
* @return Binarizer A new concrete Binarizer implementation object.
7884
*/
7985
public abstract function createBinarizer($source);
8086

81-
public final function getWidth() {
87+
public final function getWidth()
88+
{
8289
return $this->source->getWidth();
8390
}
8491

85-
public final function getHeight() {
92+
public final function getHeight()
93+
{
8694
return $this->source->getHeight();
8795
}
88-
8996
}

lib/BinaryBitmap.php

Lines changed: 66 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -17,39 +17,40 @@
1717

1818
namespace Zxing;
1919

20-
use Zxing\Common\BitArray;
2120
use Zxing\Common\BitMatrix;
2221

23-
2422
/**
2523
* This class is the core bitmap class used by ZXing to represent 1 bit data. Reader objects
2624
* accept a BinaryBitmap and attempt to decode it.
2725
*
2826
* @author [email protected] (Daniel Switkin)
2927
*/
30-
final class BinaryBitmap {
31-
32-
private $binarizer;
33-
private $matrix;
34-
35-
public function __construct($binarizer) {
36-
if ($binarizer == null) {
28+
final class BinaryBitmap
29+
{
30+
private $binarizer;
31+
private $matrix;
32+
33+
public function __construct(Binarizer $binarizer)
34+
{
35+
if ($binarizer === null) {
3736
throw new \InvalidArgumentException("Binarizer must be non-null.");
3837
}
3938
$this->binarizer = $binarizer;
4039
}
4140

4241
/**
43-
* @return The width of the bitmap.
42+
* @return int The width of the bitmap.
4443
*/
45-
public function getWidth() {
44+
public function getWidth()
45+
{
4646
return $this->binarizer->getWidth();
4747
}
4848

4949
/**
50-
* @return The height of the bitmap.
50+
* @return int The height of the bitmap.
5151
*/
52-
public function getHeight() {
52+
public function getHeight()
53+
{
5354
return $this->binarizer->getHeight();
5455
}
5556

@@ -58,95 +59,108 @@ public function getHeight() {
5859
* cached data. Callers should assume this method is expensive and call it as seldom as possible.
5960
* This method is intended for decoding 1D barcodes and may choose to apply sharpening.
6061
*
61-
* @param y The row to fetch, which must be in [0, bitmap height)
62+
* @param y The row to fetch, which must be in [0, bitmap height)
6263
* @param row An optional preallocated array. If null or too small, it will be ignored.
6364
* If used, the Binarizer will call BitArray.clear(). Always use the returned object.
64-
* @return The array of bits for this row (true means black).
65+
*
66+
* @return array The array of bits for this row (true means black).
6567
* @throws NotFoundException if row can't be binarized
6668
*/
67-
public function getBlackRow($y, $row) {
69+
public function getBlackRow($y, $row)
70+
{
6871
return $this->binarizer->getBlackRow($y, $row);
6972
}
7073

7174
/**
72-
* Converts a 2D array of luminance data to 1 bit. As above, assume this method is expensive
73-
* and do not call it repeatedly. This method is intended for decoding 2D barcodes and may or
74-
* may not apply sharpening. Therefore, a row from this matrix may not be identical to one
75-
* fetched using getBlackRow(), so don't mix and match between them.
76-
*
77-
* @return The 2D array of bits for the image (true means black).
78-
* @throws NotFoundException if image can't be binarized to make a matrix
79-
*/
80-
public function getBlackMatrix(){
81-
// The matrix is created on demand the first time it is requested, then cached. There are two
82-
// reasons for this:
83-
// 1. This work will never be done if the caller only installs 1D Reader objects, or if a
84-
// 1D Reader finds a barcode before the 2D Readers run.
85-
// 2. This work will only be done once even if the caller installs multiple 2D Readers.
86-
if ($this->matrix == null) {
87-
$this->matrix = $this->binarizer->getBlackMatrix();
88-
}
89-
return $this->matrix;
90-
}
91-
92-
/**
93-
* @return Whether this bitmap can be cropped.
75+
* @return bool Whether this bitmap can be cropped.
9476
*/
95-
public function isCropSupported() {
77+
public function isCropSupported(): bool
78+
{
9679
return $this->binarizer->getLuminanceSource()->isCropSupported();
9780
}
9881

9982
/**
10083
* Returns a new object with cropped image data. Implementations may keep a reference to the
10184
* original data rather than a copy. Only callable if isCropSupported() is true.
10285
*
103-
* @param left The left coordinate, which must be in [0,getWidth())
104-
* @param top The top coordinate, which must be in [0,getHeight())
105-
* @param width The width of the rectangle to crop.
86+
* @param left The left coordinate, which must be in [0,getWidth())
87+
* @param top The top coordinate, which must be in [0,getHeight())
88+
* @param width The width of the rectangle to crop.
10689
* @param height The height of the rectangle to crop.
107-
* @return A cropped version of this object.
90+
*
91+
* @return BinaryBitmap A cropped version of this object.
10892
*/
109-
public function crop($left, $top, $width, $height) {
93+
public function crop($left, $top, $width, $height)
94+
{
11095
$newSource = $this->binarizer->getLuminanceSource()->crop($left, $top, $width, $height);
96+
11197
return new BinaryBitmap($this->binarizer->createBinarizer($newSource));
11298
}
11399

114100
/**
115101
* @return Whether this bitmap supports counter-clockwise rotation.
116102
*/
117-
public function isRotateSupported() {
103+
public function isRotateSupported()
104+
{
118105
return $this->binarizer->getLuminanceSource()->isRotateSupported();
119106
}
120107

121108
/**
122109
* Returns a new object with rotated image data by 90 degrees counterclockwise.
123110
* Only callable if {@link #isRotateSupported()} is true.
124111
*
125-
* @return A rotated version of this object.
112+
* @return BinaryBitmap A rotated version of this object.
126113
*/
127-
public function rotateCounterClockwise() {
114+
public function rotateCounterClockwise()
115+
{
128116
$newSource = $this->binarizer->getLuminanceSource()->rotateCounterClockwise();
117+
129118
return new BinaryBitmap($this->binarizer->createBinarizer($newSource));
130119
}
131120

132121
/**
133122
* Returns a new object with rotated image data by 45 degrees counterclockwise.
134123
* Only callable if {@link #isRotateSupported()} is true.
135124
*
136-
* @return A rotated version of this object.
125+
* @return BinaryBitmap A rotated version of this object.
137126
*/
138-
public function rotateCounterClockwise45() {
127+
public function rotateCounterClockwise45()
128+
{
139129
$newSource = $this->binarizer->getLuminanceSource()->rotateCounterClockwise45();
130+
140131
return new BinaryBitmap($this->binarizer->createBinarizer($newSource));
141132
}
142133

143-
//@Override
144-
public function toString() {
134+
public function toString()
135+
{
145136
try {
146137
return $this->getBlackMatrix()->toString();
147138
} catch (NotFoundException $e) {
148-
return "";
149139
}
140+
141+
return '';
150142
}
151143

144+
/**
145+
* Converts a 2D array of luminance data to 1 bit. As above, assume this method is expensive
146+
* and do not call it repeatedly. This method is intended for decoding 2D barcodes and may or
147+
* may not apply sharpening. Therefore, a row from this matrix may not be identical to one
148+
* fetched using getBlackRow(), so don't mix and match between them.
149+
*
150+
* @return BitMatrix The 2D array of bits for the image (true means black).
151+
* @throws NotFoundException if image can't be binarized to make a matrix
152+
*/
153+
public function getBlackMatrix(): BitMatrix
154+
{
155+
// The matrix is created on demand the first time it is requested, then cached. There are two
156+
// reasons for this:
157+
// 1. This work will never be done if the caller only installs 1D Reader objects, or if a
158+
// 1D Reader finds a barcode before the 2D Readers run.
159+
// 2. This work will only be done once even if the caller installs multiple 2D Readers.
160+
if ($this->matrix === null) {
161+
$this->matrix = $this->binarizer->getBlackMatrix();
162+
}
163+
164+
return $this->matrix;
165+
}
152166
}

lib/ChecksumException.php

Lines changed: 15 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -23,22 +23,20 @@
2323
*
2424
* @author Sean Owen
2525
*/
26-
final class ChecksumException extends ReaderException {
27-
28-
private static $instance;
29-
30-
31-
32-
public static function getChecksumInstance($cause=null) {
33-
if (self::$isStackTrace) {
34-
return new ChecksumException($cause);
35-
} else {
36-
if(!self::$instance){
37-
self::$instance = new ChecksumException($cause);
26+
final class ChecksumException extends ReaderException
27+
{
28+
private static $instance;
29+
30+
public static function getChecksumInstance($cause = null)
31+
{
32+
if (self::$isStackTrace) {
33+
return new ChecksumException($cause);
34+
} else {
35+
if (!self::$instance) {
36+
self::$instance = new ChecksumException($cause);
37+
}
38+
39+
return self::$instance;
3840
}
39-
return self::$instance;
4041
}
41-
}
42-
43-
44-
}
42+
}

0 commit comments

Comments
 (0)