From dfc6eca70708e8d1379b8d50d7c63db4860d95ed Mon Sep 17 00:00:00 2001 From: codemasher Date: Wed, 19 Sep 2018 00:13:17 +0200 Subject: [PATCH] :octocat: -ClassLoader --- src/Data/QRDataAbstract.php | 6 ++---- src/QRCode.php | 15 +++++++-------- 2 files changed, 9 insertions(+), 12 deletions(-) diff --git a/src/Data/QRDataAbstract.php b/src/Data/QRDataAbstract.php index 645f53d45..fbdde905f 100644 --- a/src/Data/QRDataAbstract.php +++ b/src/Data/QRDataAbstract.php @@ -19,14 +19,13 @@ use chillerlan\QRCode\Helpers\{ BitBuffer, Polynomial }; use chillerlan\Traits\{ - ClassLoader, ImmutableSettingsInterface + ImmutableSettingsInterface }; /** * Processes the binary data and maps it on a matrix which is then being returned */ abstract class QRDataAbstract implements QRDataInterface{ - use ClassLoader; /** * the string byte count @@ -136,8 +135,7 @@ abstract class QRDataAbstract implements QRDataInterface{ * @return \chillerlan\QRCode\Data\QRMatrix */ public function initMatrix(int $maskPattern, bool $test = null):QRMatrix{ - /** @var \chillerlan\QRCode\Data\QRMatrix $matrix */ - $matrix = $this->loadClass(QRMatrix::class, null, $this->version, $this->options->eccLevel); + $matrix = new QRMatrix($this->version, $this->options->eccLevel); return $matrix ->setFinderPattern() diff --git a/src/QRCode.php b/src/QRCode.php index 13ba93ae6..94037ade1 100755 --- a/src/QRCode.php +++ b/src/QRCode.php @@ -19,7 +19,7 @@ use chillerlan\QRCode\Output\{ QRCodeOutputException, QRImage, QRMarkup, QROutputInterface, QRString }; use chillerlan\Traits\{ - ClassLoader, ImmutableSettingsInterface + ImmutableSettingsInterface }; /** @@ -30,7 +30,6 @@ use chillerlan\Traits\{ * @link http://www.thonky.com/qr-code-tutorial/ */ class QRCode{ - use ClassLoader; /** * API constants @@ -229,8 +228,8 @@ class QRCode{ foreach($DATA_MODES as $dataInterface => $mode){ - if(call_user_func_array([$this, 'is'.$mode], [$data]) === true){ - return $this->loadClass($dataInterface, QRDataInterface::class, $this->options, $data); + if(call_user_func_array([$this, 'is'.$mode], [$data]) === true && class_exists($dataInterface)){ + return new $dataInterface($this->options, $data); } } @@ -248,14 +247,14 @@ class QRCode{ */ protected function initOutputInterface(string $data):QROutputInterface{ - if($this->options->outputType === $this::OUTPUT_CUSTOM && $this->options->outputInterface !== null){ - return $this->loadClass($this->options->outputInterface, QROutputInterface::class, $this->options, $this->getMatrix($data)); + if($this->options->outputType === $this::OUTPUT_CUSTOM && class_exists($this->options->outputInterface)){ + return new $this->options->outputInterface($this->options, $this->getMatrix($data)); } foreach($this::OUTPUT_MODES as $outputInterface => $modes){ - if(in_array($this->options->outputType, $modes, true)){ - return $this->loadClass($outputInterface, QROutputInterface::class, $this->options, $this->getMatrix($data)); + if(in_array($this->options->outputType, $modes, true) && class_exists($outputInterface)){ + return new $outputInterface($this->options, $this->getMatrix($data)); } }