mirror of
https://github.com/chillerlan/php-qrcode.git
synced 2026-08-18 12:10:06 +00:00
:octocat: +readFromSource()
This commit is contained in:
+20
-12
@@ -12,7 +12,7 @@ namespace chillerlan\QRCode;
|
||||
|
||||
use chillerlan\QRCode\Common\{ECICharset, MaskPattern, MaskPatternTester, Mode};
|
||||
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\Settings\SettingsContainerInterface;
|
||||
use function class_exists, class_implements, in_array, mb_convert_encoding, mb_detect_encoding;
|
||||
@@ -248,6 +248,15 @@ class QRCode{
|
||||
$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
|
||||
*/
|
||||
@@ -316,21 +325,12 @@ class QRCode{
|
||||
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
|
||||
*/
|
||||
public function readFromFile(string $path):DecoderResult{
|
||||
/** @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{
|
||||
/** @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);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user