|
19 | 19 | use chillerlan\QRCode\Decoder\{Decoder, DecoderResult};
|
20 | 20 | use chillerlan\QRCode\Output\{QRCodeOutputException, QROutputInterface};
|
21 | 21 | use chillerlan\Settings\SettingsContainerInterface;
|
22 |
| -use function class_exists, class_implements, in_array, mb_convert_encoding, mb_internal_encoding; |
| 22 | +use function class_exists, class_implements, in_array, is_iterable, mb_convert_encoding, mb_internal_encoding; |
23 | 23 |
|
24 | 24 | /**
|
25 | 25 | * Turns a text string into a Model 2 QR Code
|
@@ -51,17 +51,20 @@ class QRCode{
|
51 | 51 |
|
52 | 52 | /**
|
53 | 53 | * QRCode constructor.
|
54 |
| - * |
55 |
| - * PHP8: accept iterable |
56 | 54 | */
|
57 |
| - public function __construct(SettingsContainerInterface|QROptions $options = new QROptions){ |
| 55 | + public function __construct(SettingsContainerInterface|QROptions|iterable $options = new QROptions){ |
58 | 56 | $this->setOptions($options);
|
59 | 57 | }
|
60 | 58 |
|
61 | 59 | /**
|
62 | 60 | * Sets an options instance
|
63 | 61 | */
|
64 |
| - public function setOptions(SettingsContainerInterface|QROptions $options):static{ |
| 62 | + public function setOptions(SettingsContainerInterface|QROptions|iterable $options):static{ |
| 63 | + |
| 64 | + if(is_iterable($options)){ |
| 65 | + $options = new QROptions($options); |
| 66 | + } |
| 67 | + |
65 | 68 | $this->options = $options;
|
66 | 69 |
|
67 | 70 | if($this->options->readerUseImagickIfAvailable){
|
@@ -265,17 +268,13 @@ public function addEciSegment(int $encoding, string $data):static{
|
265 | 268 |
|
266 | 269 | /**
|
267 | 270 | * Reads a QR Code from a given file
|
268 |
| - * |
269 |
| - * @noinspection PhpUndefinedMethodInspection |
270 | 271 | */
|
271 | 272 | public function readFromFile(string $path):DecoderResult{
|
272 | 273 | return $this->readFromSource($this->luminanceSourceFQN::fromFile($path, $this->options));
|
273 | 274 | }
|
274 | 275 |
|
275 | 276 | /**
|
276 | 277 | * Reads a QR Code from the given data blob
|
277 |
| - * |
278 |
| - * @noinspection PhpUndefinedMethodInspection |
279 | 278 | */
|
280 | 279 | public function readFromBlob(string $blob):DecoderResult{
|
281 | 280 | return $this->readFromSource($this->luminanceSourceFQN::fromBlob($blob, $this->options));
|
|
0 commit comments