diff --git a/examples/custom.php b/examples/custom.php
index 21c92b812..7d5f20520 100644
--- a/examples/custom.php
+++ b/examples/custom.php
@@ -3,7 +3,6 @@
require_once '../vendor/autoload.php';
use chillerlan\QRCode\QRCode;
-use chillerlan\QRCode\QRConst;
use chillerlan\QRCode\QROptions;
use chillerlan\QRCode\Output\QRString;
use chillerlan\QRCode\Output\QRStringOptions;
@@ -11,11 +10,11 @@ use chillerlan\QRCode\Output\QRStringOptions;
$starttime = microtime(true);
$qrOptions = new QROptions;
-$qrOptions->typeNumber = QRConst::TYPE_05;
-$qrOptions->errorCorrectLevel = QRConst::ERROR_CORRECT_LEVEL_M;
+$qrOptions->typeNumber = QRCode::TYPE_05;
+$qrOptions->errorCorrectLevel = QRCode::ERROR_CORRECT_LEVEL_M;
$qrStringOptions = new QRStringOptions;
-$qrStringOptions->type = QRConst::OUTPUT_STRING_TEXT;
+$qrStringOptions->type = QRCode::OUTPUT_STRING_TEXT;
$qrStringOptions->textDark = '+';
$qrStringOptions->textLight = '-';
diff --git a/examples/html.php b/examples/html.php
index b96db36be..8a13aeab7 100644
--- a/examples/html.php
+++ b/examples/html.php
@@ -5,7 +5,6 @@ require_once '../vendor/autoload.php';
use chillerlan\QRCode\Output\QRString;
use chillerlan\QRCode\Output\QRStringOptions;
use chillerlan\QRCode\QRCode;
-use chillerlan\QRCode\QRConst;
use chillerlan\QRCode\QROptions;
//---------------------------------------------------------
@@ -44,13 +43,12 @@ echo '';
$qrStringOptions = new QRStringOptions;
-$qrStringOptions->type = QRConst::OUTPUT_STRING_HTML;
+$qrStringOptions->type = QRCode::OUTPUT_STRING_HTML;
$qrOptions = new QROptions;
-$qrOptions->typeNumber = QRConst::TYPE_05;
-$qrOptions->errorCorrectLevel = QRConst::ERROR_CORRECT_LEVEL_M;
-$qrOptions->output = new QRString($qrStringOptions);
+$qrOptions->typeNumber = QRCode::TYPE_05;
+$qrOptions->errorCorrectLevel = QRCode::ERROR_CORRECT_LEVEL_M;
-$qr = new QRCode('skype://callto:echo123', $qrOptions);
+$qr = new QRCode('skype://callto:echo123', new QRString($qrStringOptions), $qrOptions);
echo '
'.$qr->output().'
';
diff --git a/src/Output/QRString.php b/src/Output/QRString.php
index 1db91eedf..3537de246 100644
--- a/src/Output/QRString.php
+++ b/src/Output/QRString.php
@@ -11,7 +11,7 @@
*/
namespace chillerlan\QRCode\Output;
-use chillerlan\QRCode\QRConst;
+use chillerlan\QRCode\QRCode;
/**
*
@@ -42,9 +42,9 @@ class QRString extends QROutputBase implements QROutputInterface{
public function dump(){
switch($this->options->type){
- case QRConst::OUTPUT_STRING_TEXT: return $this->toText();
- case QRConst::OUTPUT_STRING_JSON: return $this->toJSON();
- case QRConst::OUTPUT_STRING_HTML: return $this->toHTML();
+ case QRCode::OUTPUT_STRING_TEXT: return $this->toText();
+ case QRCode::OUTPUT_STRING_JSON: return $this->toJSON();
+ case QRCode::OUTPUT_STRING_HTML: return $this->toHTML();
default:
throw new QRCodeOutputException('Invalid string output type!');
}
diff --git a/src/Output/QRStringOptions.php b/src/Output/QRStringOptions.php
index 3ef06c3b9..04fece1ce 100644
--- a/src/Output/QRStringOptions.php
+++ b/src/Output/QRStringOptions.php
@@ -11,14 +11,14 @@
*/
namespace chillerlan\QRCode\Output;
-use chillerlan\QRCode\QRConst;
+use chillerlan\QRCode\QRCode;
/**
*
*/
class QRStringOptions{
- public $type = QRConst::OUTPUT_STRING_TEXT;
+ public $type = QRCode::OUTPUT_STRING_TEXT;
public $textDark = '#';
diff --git a/src/QRCode.php b/src/QRCode.php
index 13cbcf5db..797754908 100644
--- a/src/QRCode.php
+++ b/src/QRCode.php
@@ -19,6 +19,34 @@ use chillerlan\QRCode\Output\QROutputInterface;
*/
class QRCode{
+ /**
+ * API constants
+ */
+ const OUTPUT_STRING_TEXT = 0;
+ const OUTPUT_STRING_JSON = 1;
+ const OUTPUT_STRING_HTML = 2;
+
+ const OUTPUT_IMAGE_PNG = 0;
+ const OUTPUT_IMAGE_JPG = 1;
+ const OUTPUT_IMAGE_GIF = 2;
+
+ const ERROR_CORRECT_LEVEL_L = 1; // 7%.
+ const ERROR_CORRECT_LEVEL_M = 0; // 15%.
+ const ERROR_CORRECT_LEVEL_Q = 3; // 25%.
+ const ERROR_CORRECT_LEVEL_H = 2; // 30%.
+
+ // max bits @ ec level L:07 M:15 Q:25 H:30 %
+ const TYPE_01 = 1; // 152 128 104 72
+ const TYPE_02 = 2; // 272 224 176 128
+ const TYPE_03 = 3; // 440 352 272 208
+ const TYPE_04 = 4; // 640 512 384 288
+ const TYPE_05 = 5; // 864 688 496 368
+ const TYPE_06 = 6; // 1088 864 608 480
+ const TYPE_07 = 7; // 1248 992 704 528
+ const TYPE_08 = 8; // 1552 1232 880 688
+ const TYPE_09 = 9; // 1856 1456 1056 800
+ const TYPE_10 = 10; // 2192 1728 1232 976
+
/**
* @var array
*/
diff --git a/src/QRConst.php b/src/QRConst.php
index 65c4090c1..2989661cd 100644
--- a/src/QRConst.php
+++ b/src/QRConst.php
@@ -17,45 +17,24 @@ namespace chillerlan\QRCode;
*/
class QRConst{
- const OUTPUT_STRING_TEXT = 0;
- const OUTPUT_STRING_JSON = 1;
- const OUTPUT_STRING_HTML = 2;
-
- const ERROR_CORRECT_LEVEL_L = 1; // 7%.
- const ERROR_CORRECT_LEVEL_M = 0; // 15%.
- const ERROR_CORRECT_LEVEL_Q = 3; // 25%.
- const ERROR_CORRECT_LEVEL_H = 2; // 30%.
-
const RSBLOCK = [
- self::ERROR_CORRECT_LEVEL_L => 0,
- self::ERROR_CORRECT_LEVEL_M => 1,
- self::ERROR_CORRECT_LEVEL_Q => 2,
- self::ERROR_CORRECT_LEVEL_H => 3,
+ QRCode::ERROR_CORRECT_LEVEL_L => 0,
+ QRCode::ERROR_CORRECT_LEVEL_M => 1,
+ QRCode::ERROR_CORRECT_LEVEL_Q => 2,
+ QRCode::ERROR_CORRECT_LEVEL_H => 3,
];
- // max bits @ ec level L:07 M:15 Q:25 H:30 %
- const TYPE_01 = 1; // 152 128 104 72
- const TYPE_02 = 2; // 272 224 176 128
- const TYPE_03 = 3; // 440 352 272 208
- const TYPE_04 = 4; // 640 512 384 288
- const TYPE_05 = 5; // 864 688 496 368
- const TYPE_06 = 6; // 1088 864 608 480
- const TYPE_07 = 7; // 1248 992 704 528
- const TYPE_08 = 8; // 1552 1232 880 688
- const TYPE_09 = 9; // 1856 1456 1056 800
- const TYPE_10 = 10; // 2192 1728 1232 976
-
const MAX_BITS = [
- self::TYPE_01 => [ 128, 152, 72, 104],
- self::TYPE_02 => [ 224, 272, 128, 176],
- self::TYPE_03 => [ 352, 440, 208, 272],
- self::TYPE_04 => [ 512, 640, 288, 384],
- self::TYPE_05 => [ 688, 864, 368, 496],
- self::TYPE_06 => [ 864, 1088, 480, 608],
- self::TYPE_07 => [ 992, 1248, 528, 704],
- self::TYPE_08 => [1232, 1552, 688, 880],
- self::TYPE_09 => [1456, 1856, 800, 1056],
- self::TYPE_10 => [1728, 2192, 976, 1232],
+ QRCode::TYPE_01 => [ 128, 152, 72, 104],
+ QRCode::TYPE_02 => [ 224, 272, 128, 176],
+ QRCode::TYPE_03 => [ 352, 440, 208, 272],
+ QRCode::TYPE_04 => [ 512, 640, 288, 384],
+ QRCode::TYPE_05 => [ 688, 864, 368, 496],
+ QRCode::TYPE_06 => [ 864, 1088, 480, 608],
+ QRCode::TYPE_07 => [ 992, 1248, 528, 704],
+ QRCode::TYPE_08 => [1232, 1552, 688, 880],
+ QRCode::TYPE_09 => [1456, 1856, 800, 1056],
+ QRCode::TYPE_10 => [1728, 2192, 976, 1232],
];
const MODE_NUMBER = 1 << 0;
diff --git a/src/QROptions.php b/src/QROptions.php
index 4ac5f1926..ebad37662 100644
--- a/src/QROptions.php
+++ b/src/QROptions.php
@@ -20,7 +20,7 @@ class QROptions{
/**
* @var int
*/
- public $errorCorrectLevel = QRConst::ERROR_CORRECT_LEVEL_M;
+ public $errorCorrectLevel = QRCode::ERROR_CORRECT_LEVEL_M;
/**
* @var int