|
@@ -12,7 +12,7 @@ namespace chillerlan\QRCode;
|
|
|
|
|
|
|
|
use chillerlan\QRCode\Common\{ECICharset, MaskPattern, MaskPatternTester, Mode};
|
|
use chillerlan\QRCode\Common\{ECICharset, MaskPattern, MaskPatternTester, Mode};
|
|
|
use chillerlan\QRCode\Data\{AlphaNum, Byte, ECI, Kanji, Number, QRData, QRCodeDataException, QRDataModeInterface, QRMatrix};
|
|
use chillerlan\QRCode\Data\{AlphaNum, Byte, ECI, Kanji, Number, QRData, QRCodeDataException, QRDataModeInterface, QRMatrix};
|
|
|
-use chillerlan\QRCode\Decoder\{Decoder, DecoderResult, GDLuminanceSource, IMagickLuminanceSource};
|
|
|
|
|
|
|
+use chillerlan\QRCode\Decoder\{Decoder, DecoderResult, GDLuminanceSource, IMagickLuminanceSource, LuminanceSourceInterface};
|
|
|
use chillerlan\QRCode\Output\{QRCodeOutputException, QRFpdf, QRImage, QRImagick, QRMarkup, QROutputInterface, QRString};
|
|
use chillerlan\QRCode\Output\{QRCodeOutputException, QRFpdf, QRImage, QRImagick, QRMarkup, QROutputInterface, QRString};
|
|
|
use chillerlan\Settings\SettingsContainerInterface;
|
|
use chillerlan\Settings\SettingsContainerInterface;
|
|
|
use function class_exists, class_implements, in_array, mb_convert_encoding, mb_detect_encoding;
|
|
use function class_exists, class_implements, in_array, mb_convert_encoding, mb_detect_encoding;
|
|
@@ -248,6 +248,15 @@ class QRCode{
|
|
|
$this->dataSegments[] = $segment;
|
|
$this->dataSegments[] = $segment;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ /**
|
|
|
|
|
+ * Clears the data segments array
|
|
|
|
|
+ */
|
|
|
|
|
+ public function clearSegments():self{
|
|
|
|
|
+ $this->dataSegments = [];
|
|
|
|
|
+
|
|
|
|
|
+ return $this;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
/**
|
|
/**
|
|
|
* ISO/IEC 18004:2000 8.3.2 - Numeric Mode
|
|
* ISO/IEC 18004:2000 8.3.2 - Numeric Mode
|
|
|
*/
|
|
*/
|
|
@@ -316,21 +325,12 @@ class QRCode{
|
|
|
throw new QRCodeException('unable to add ECI segment');
|
|
throw new QRCodeException('unable to add ECI segment');
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- /**
|
|
|
|
|
- * Clears the data segments array
|
|
|
|
|
- */
|
|
|
|
|
- public function clearSegments():self{
|
|
|
|
|
- $this->dataSegments = [];
|
|
|
|
|
-
|
|
|
|
|
- return $this;
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
/**
|
|
/**
|
|
|
* Reads a QR Code from a given file
|
|
* Reads a QR Code from a given file
|
|
|
*/
|
|
*/
|
|
|
public function readFromFile(string $path):DecoderResult{
|
|
public function readFromFile(string $path):DecoderResult{
|
|
|
/** @noinspection PhpUndefinedMethodInspection */
|
|
/** @noinspection PhpUndefinedMethodInspection */
|
|
|
- return (new Decoder)->decode($this->luminanceSourceClass::fromFile($path));
|
|
|
|
|
|
|
+ return $this->readFromSource($this->luminanceSourceClass::fromFile($path));
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -338,7 +338,15 @@ class QRCode{
|
|
|
*/
|
|
*/
|
|
|
public function readFromBlob(string $blob):DecoderResult{
|
|
public function readFromBlob(string $blob):DecoderResult{
|
|
|
/** @noinspection PhpUndefinedMethodInspection */
|
|
/** @noinspection PhpUndefinedMethodInspection */
|
|
|
- return (new Decoder)->decode($this->luminanceSourceClass::fromBlob($blob));
|
|
|
|
|
|
|
+ return $this->readFromSource($this->luminanceSourceClass::fromBlob($blob));
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * Reads a QR Code from the given luminance source
|
|
|
|
|
+ */
|
|
|
|
|
+ public function readFromSource(LuminanceSourceInterface $source):DecoderResult{
|
|
|
|
|
+ /** @noinspection PhpUndefinedMethodInspection */
|
|
|
|
|
+ return (new Decoder)->decode($source);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
}
|
|
}
|