summaryrefslogtreecommitdiffstats
path: root/src/PHPZxing
diff options
context:
space:
mode:
Diffstat (limited to 'src/PHPZxing')
-rw-r--r--src/PHPZxing/PHPZxingBase.php4
-rw-r--r--src/PHPZxing/PHPZxingDecoder.php16
-rw-r--r--src/PHPZxing/PHPZxingInterface.php39
-rw-r--r--src/PHPZxing/ZxingBarNotFound.php12
-rw-r--r--src/PHPZxing/ZxingImage.php12
5 files changed, 72 insertions, 11 deletions
diff --git a/src/PHPZxing/PHPZxingBase.php b/src/PHPZxing/PHPZxingBase.php
index 5d3cc79..fbad3fe 100644
--- a/src/PHPZxing/PHPZxingBase.php
+++ b/src/PHPZxing/PHPZxingBase.php
@@ -8,8 +8,8 @@ authors:
- Siddharth Deshpande (dsiddharth2@gmail.com)
...
* PHPZxing
-* Version 1.0
-* Copyright (c) 2017 Siddharth Deshpande
+* Version 1.0.1
+* Copyright (c) 2018 Siddharth Deshpande
*
* Permission is hereby granted, free of charge, to any person
* obtaining a copy of this software and associated documentation
diff --git a/src/PHPZxing/PHPZxingDecoder.php b/src/PHPZxing/PHPZxingDecoder.php
index 7ab7804..42176da 100644
--- a/src/PHPZxing/PHPZxingDecoder.php
+++ b/src/PHPZxing/PHPZxingDecoder.php
@@ -15,8 +15,8 @@ Provides: PHPZxingDecoder
-
...
* PHPZxingDecoder
-* Version 1.0
-* Copyright (c) 2017 Siddharth Deshpande
+* Version 1.0.1
+* Copyright (c) 2018 Siddharth Deshpande
*
* Permission is hereby granted, free of charge, to any person
* obtaining a copy of this software and associated documentation
@@ -79,7 +79,11 @@ class PHPZxingDecoder extends PHPZxingBase {
if(isset($config['crop']) && array_key_exists('crop', $config)) {
$this->crop = strval($config['crop']);
- }
+ }
+
+ if(isset($config['returnAs']) && array_key_exists('returnAs', $config)) {
+ $this->returnAs = strval($config['returnAs']);
+ }
}
private function basePrepare() {
@@ -170,6 +174,7 @@ class PHPZxingDecoder extends PHPZxingBase {
$image[] = new ZxingImage($imagePath, $imageValue, $format, $type);
} else if(preg_match('/No barcode found/', $singleLine)) {
+
$exploded = explode(" ", $singleLine);
$imagePath = array_shift($exploded);
$image[] = new ZxingBarNotFound($imagePath, 101, "No barcode found");
@@ -230,6 +235,11 @@ class PHPZxingDecoder extends PHPZxingBase {
throw new \Exception("Is the java PATH set correctly ? Current Path set is : " . $this->getJavaPath());
}
+ // If the image is single then return the actual image
+ if(count($image) == 1) {
+ return current($image);
+ }
+
return $image;
} catch(\Exception $e) {
echo $e->getMessage();
diff --git a/src/PHPZxing/PHPZxingInterface.php b/src/PHPZxing/PHPZxingInterface.php
new file mode 100644
index 0000000..d9568f8
--- /dev/null
+++ b/src/PHPZxing/PHPZxingInterface.php
@@ -0,0 +1,39 @@
+<?php
+/*
+Descrition : PHPZxingInterface interface that will have all the interface methods stored
+
+license: MIT-style
+
+authors:
+- Siddharth Deshpande (dsiddharth2@gmail.com)
+...
+* PHPZxing
+* Version 1.0.1
+* Copyright (c) 2018 Siddharth Deshpande
+*
+* Permission is hereby granted, free of charge, to any person
+* obtaining a copy of this software and associated documentation
+* files (the "Software"), to deal in the Software without
+* restriction, including without limitation the rights to use,
+* copy, modify, merge, publish, distribute, sublicense, and/or sell
+* copies of the Software, and to permit persons to whom the
+* Software is furnished to do so, subject to the following
+* conditions:
+*
+* The above copyright notice and this permission notice shall be
+* included in all copies or substantial portions of the Software.
+*
+* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
+* OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
+* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+* OTHER DEALINGS IN THE SOFTWARE.
+*/
+namespace PHPZxing;
+
+interface PHPZxingInterface {
+ public function isFound();
+} \ No newline at end of file
diff --git a/src/PHPZxing/ZxingBarNotFound.php b/src/PHPZxing/ZxingBarNotFound.php
index 608d743..4e7ddb7 100644
--- a/src/PHPZxing/ZxingBarNotFound.php
+++ b/src/PHPZxing/ZxingBarNotFound.php
@@ -9,8 +9,8 @@ authors:
- Siddharth Deshpande (dsiddharth2@gmail.com)
...
* PHPZxing
-* Version 1.0
-* Copyright (c) 2017 Siddharth Deshpande
+* Version 1.0.1
+* Copyright (c) 2018 Siddharth Deshpande
*
* Permission is hereby granted, free of charge, to any person
* obtaining a copy of this software and associated documentation
@@ -36,7 +36,9 @@ authors:
namespace PHPZxing;
-class ZxingBarNotFound {
+use PHPZxing\PHPZxingInterface;
+
+class ZxingBarNotFound implements PHPZxingInterface {
// Path of the image decoded
private $imagePath = null;
@@ -63,4 +65,8 @@ class ZxingBarNotFound {
public function getErrorMessage() {
return $this->message;
}
+
+ public function isFound() {
+ return false;
+ }
} \ No newline at end of file
diff --git a/src/PHPZxing/ZxingImage.php b/src/PHPZxing/ZxingImage.php
index d36f560..d49131b 100644
--- a/src/PHPZxing/ZxingImage.php
+++ b/src/PHPZxing/ZxingImage.php
@@ -8,8 +8,8 @@ authors:
- Siddharth Deshpande (dsiddharth2@gmail.com)
...
* PHPZxing
-* Version 1.0
-* Copyright (c) 2017 Siddharth Deshpande
+* Version 1.0.1
+* Copyright (c) 2018 Siddharth Deshpande
*
* Permission is hereby granted, free of charge, to any person
* obtaining a copy of this software and associated documentation
@@ -34,7 +34,9 @@ authors:
*/
namespace PHPZxing;
-class ZxingImage {
+use PHPZxing\PHPZxingInterface;
+
+class ZxingImage implements PHPZxingInterface {
// Decoded Value from source
private $imageValue = null;
@@ -54,6 +56,10 @@ class ZxingImage {
$this->imagePath = $imagePath;
}
+ public function isFound() {
+ return true;
+ }
+
public function getImageValue() {
return $this->imageValue;
}