@@ -27,7 +27,7 @@ discard block |
||
| 27 | 27 | * @see \sprintf() |
| 28 | 28 | */ |
| 29 | 29 | protected string $svgHeader = '<svg xmlns="http://www.w3.org/2000/svg" class="qr-svg %1$s" '. |
| 30 | - 'style="width: 100%%; height: auto;" viewBox="0 0 %2$d %2$d">'; |
|
| 30 | + 'style="width: 100%%; height: auto;" viewBox="0 0 %2$d %2$d">'; |
|
| 31 | 31 | |
| 32 | 32 | /** |
| 33 | 33 | * @inheritDoc |
@@ -75,8 +75,8 @@ discard block |
||
| 75 | 75 | |
| 76 | 76 | if($file !== null){ |
| 77 | 77 | return '<!DOCTYPE html>'. |
| 78 | - '<head><meta charset="UTF-8"><title>QR Code</title></head>'. |
|
| 79 | - '<body>'.$this->options->eol.$html.'</body>'; |
|
| 78 | + '<head><meta charset="UTF-8"><title>QR Code</title></head>'. |
|
| 79 | + '<body>'.$this->options->eol.$html.'</body>'; |
|
| 80 | 80 | } |
| 81 | 81 | |
| 82 | 82 | return $html; |
@@ -91,9 +91,9 @@ discard block |
||
| 91 | 91 | $matrix = $this->matrix->matrix(); |
| 92 | 92 | |
| 93 | 93 | $svg = sprintf($this->svgHeader, $this->options->cssClass, $this->options->svgViewBoxSize ?? $this->moduleCount) |
| 94 | - .$this->options->eol |
|
| 95 | - .'<defs>'.$this->options->svgDefs.'</defs>' |
|
| 96 | - .$this->options->eol; |
|
| 94 | + .$this->options->eol |
|
| 95 | + .'<defs>'.$this->options->svgDefs.'</defs>' |
|
| 96 | + .$this->options->eol; |
|
| 97 | 97 | |
| 98 | 98 | foreach($this->moduleValues as $M_TYPE => $value){ |
| 99 | 99 | $path = ''; |
@@ -147,7 +147,7 @@ discard block |
||
| 147 | 147 | // if saving to file, append the correct headers |
| 148 | 148 | if($file !== null){ |
| 149 | 149 | return '<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">'. |
| 150 | - $this->options->eol.$svg; |
|
| 150 | + $this->options->eol.$svg; |
|
| 151 | 151 | } |
| 152 | 152 | |
| 153 | 153 | return $svg; |
@@ -15,66 +15,66 @@ |
||
| 15 | 15 | */ |
| 16 | 16 | class QRFpdf extends QROutputAbstract |
| 17 | 17 | { |
| 18 | - public function __construct(SettingsContainerInterface $options, QRMatrix $matrix) |
|
| 19 | - { |
|
| 20 | - parent::__construct($options, $matrix); |
|
| 18 | + public function __construct(SettingsContainerInterface $options, QRMatrix $matrix) |
|
| 19 | + { |
|
| 20 | + parent::__construct($options, $matrix); |
|
| 21 | 21 | |
| 22 | - if (!\class_exists(\FPDF::class)) { |
|
| 23 | - throw new \BadMethodCallException( |
|
| 24 | - 'The QRFpdf output requires FPDF as dependency but the class "\FPDF" couldn\'t be found.' |
|
| 25 | - ); |
|
| 26 | - } |
|
| 27 | - } |
|
| 22 | + if (!\class_exists(\FPDF::class)) { |
|
| 23 | + throw new \BadMethodCallException( |
|
| 24 | + 'The QRFpdf output requires FPDF as dependency but the class "\FPDF" couldn\'t be found.' |
|
| 25 | + ); |
|
| 26 | + } |
|
| 27 | + } |
|
| 28 | 28 | |
| 29 | - /** |
|
| 30 | - * @inheritDoc |
|
| 31 | - */ |
|
| 32 | - protected function setModuleValues(): void |
|
| 33 | - { |
|
| 34 | - foreach ($this::DEFAULT_MODULE_VALUES as $M_TYPE => $defaultValue) { |
|
| 35 | - $v = $this->options->moduleValues[$M_TYPE] ?? null; |
|
| 29 | + /** |
|
| 30 | + * @inheritDoc |
|
| 31 | + */ |
|
| 32 | + protected function setModuleValues(): void |
|
| 33 | + { |
|
| 34 | + foreach ($this::DEFAULT_MODULE_VALUES as $M_TYPE => $defaultValue) { |
|
| 35 | + $v = $this->options->moduleValues[$M_TYPE] ?? null; |
|
| 36 | 36 | |
| 37 | - if (!\is_array($v) || \count($v) < 3) { |
|
| 38 | - $this->moduleValues[$M_TYPE] = $defaultValue |
|
| 39 | - ? [0, 0, 0] |
|
| 40 | - : [255, 255, 255]; |
|
| 41 | - } else { |
|
| 42 | - $this->moduleValues[$M_TYPE] = \array_values($v); |
|
| 43 | - } |
|
| 44 | - } |
|
| 45 | - } |
|
| 37 | + if (!\is_array($v) || \count($v) < 3) { |
|
| 38 | + $this->moduleValues[$M_TYPE] = $defaultValue |
|
| 39 | + ? [0, 0, 0] |
|
| 40 | + : [255, 255, 255]; |
|
| 41 | + } else { |
|
| 42 | + $this->moduleValues[$M_TYPE] = \array_values($v); |
|
| 43 | + } |
|
| 44 | + } |
|
| 45 | + } |
|
| 46 | 46 | |
| 47 | - /** |
|
| 48 | - * @inheritDoc |
|
| 49 | - */ |
|
| 50 | - public function dump(string $file = null): string |
|
| 51 | - { |
|
| 52 | - $file ??= $this->options->cachefile; |
|
| 47 | + /** |
|
| 48 | + * @inheritDoc |
|
| 49 | + */ |
|
| 50 | + public function dump(string $file = null): string |
|
| 51 | + { |
|
| 52 | + $file ??= $this->options->cachefile; |
|
| 53 | 53 | |
| 54 | - $fpdf = new \FPDF('P', 'pt', [$this->length, $this->length]); |
|
| 55 | - $fpdf->AddPage(); |
|
| 54 | + $fpdf = new \FPDF('P', 'pt', [$this->length, $this->length]); |
|
| 55 | + $fpdf->AddPage(); |
|
| 56 | 56 | |
| 57 | - $prevColor = null; |
|
| 58 | - foreach ($this->matrix->matrix() as $y => $row) { |
|
| 59 | - foreach ($row as $x => $M_TYPE) { |
|
| 60 | - /** |
|
| 61 | - * @var int $M_TYPE |
|
| 62 | - */ |
|
| 63 | - $color = $this->moduleValues[$M_TYPE]; |
|
| 64 | - if ($prevColor === null || $prevColor !== $color) { |
|
| 65 | - $fpdf->SetFillColor(...$color); |
|
| 66 | - $prevColor = $color; |
|
| 67 | - } |
|
| 68 | - $fpdf->Rect($x * $this->scale, $y * $this->scale, 1 * $this->scale, 1 * $this->scale, 'F'); |
|
| 69 | - } |
|
| 70 | - } |
|
| 57 | + $prevColor = null; |
|
| 58 | + foreach ($this->matrix->matrix() as $y => $row) { |
|
| 59 | + foreach ($row as $x => $M_TYPE) { |
|
| 60 | + /** |
|
| 61 | + * @var int $M_TYPE |
|
| 62 | + */ |
|
| 63 | + $color = $this->moduleValues[$M_TYPE]; |
|
| 64 | + if ($prevColor === null || $prevColor !== $color) { |
|
| 65 | + $fpdf->SetFillColor(...$color); |
|
| 66 | + $prevColor = $color; |
|
| 67 | + } |
|
| 68 | + $fpdf->Rect($x * $this->scale, $y * $this->scale, 1 * $this->scale, 1 * $this->scale, 'F'); |
|
| 69 | + } |
|
| 70 | + } |
|
| 71 | 71 | |
| 72 | - $pdfData = $fpdf->Output('S'); |
|
| 72 | + $pdfData = $fpdf->Output('S'); |
|
| 73 | 73 | |
| 74 | - if ($file !== null) { |
|
| 75 | - $this->saveToFile($pdfData, $file); |
|
| 76 | - } |
|
| 74 | + if ($file !== null) { |
|
| 75 | + $this->saveToFile($pdfData, $file); |
|
| 76 | + } |
|
| 77 | 77 | |
| 78 | - return $pdfData; |
|
| 79 | - } |
|
| 78 | + return $pdfData; |
|
| 79 | + } |
|
| 80 | 80 | } |
@@ -13,13 +13,11 @@ discard block |
||
| 13 | 13 | * @see https://github.com/Setasign/FPDF |
| 14 | 14 | * @see http://www.fpdf.org/ |
| 15 | 15 | */ |
| 16 | -class QRFpdf extends QROutputAbstract |
|
| 17 | -{ |
|
| 18 | - public function __construct(SettingsContainerInterface $options, QRMatrix $matrix) |
|
| 19 | - { |
|
| 16 | +class QRFpdf extends QROutputAbstract{ |
|
| 17 | + public function __construct(SettingsContainerInterface $options, QRMatrix $matrix){ |
|
| 20 | 18 | parent::__construct($options, $matrix); |
| 21 | 19 | |
| 22 | - if (!\class_exists(\FPDF::class)) { |
|
| 20 | + if (!\class_exists(\FPDF::class)){ |
|
| 23 | 21 | throw new \BadMethodCallException( |
| 24 | 22 | 'The QRFpdf output requires FPDF as dependency but the class "\FPDF" couldn\'t be found.' |
| 25 | 23 | ); |
@@ -31,14 +29,15 @@ discard block |
||
| 31 | 29 | */ |
| 32 | 30 | protected function setModuleValues(): void |
| 33 | 31 | { |
| 34 | - foreach ($this::DEFAULT_MODULE_VALUES as $M_TYPE => $defaultValue) { |
|
| 32 | + foreach ($this::DEFAULT_MODULE_VALUES as $M_TYPE => $defaultValue){ |
|
| 35 | 33 | $v = $this->options->moduleValues[$M_TYPE] ?? null; |
| 36 | 34 | |
| 37 | - if (!\is_array($v) || \count($v) < 3) { |
|
| 35 | + if (!\is_array($v) || \count($v) < 3){ |
|
| 38 | 36 | $this->moduleValues[$M_TYPE] = $defaultValue |
| 39 | 37 | ? [0, 0, 0] |
| 40 | 38 | : [255, 255, 255]; |
| 41 | - } else { |
|
| 39 | + } |
|
| 40 | + else{ |
|
| 42 | 41 | $this->moduleValues[$M_TYPE] = \array_values($v); |
| 43 | 42 | } |
| 44 | 43 | } |
@@ -55,13 +54,13 @@ discard block |
||
| 55 | 54 | $fpdf->AddPage(); |
| 56 | 55 | |
| 57 | 56 | $prevColor = null; |
| 58 | - foreach ($this->matrix->matrix() as $y => $row) { |
|
| 59 | - foreach ($row as $x => $M_TYPE) { |
|
| 57 | + foreach ($this->matrix->matrix() as $y => $row){ |
|
| 58 | + foreach ($row as $x => $M_TYPE){ |
|
| 60 | 59 | /** |
| 61 | 60 | * @var int $M_TYPE |
| 62 | 61 | */ |
| 63 | 62 | $color = $this->moduleValues[$M_TYPE]; |
| 64 | - if ($prevColor === null || $prevColor !== $color) { |
|
| 63 | + if ($prevColor === null || $prevColor !== $color){ |
|
| 65 | 64 | $fpdf->SetFillColor(...$color); |
| 66 | 65 | $prevColor = $color; |
| 67 | 66 | } |
@@ -71,7 +70,7 @@ discard block |
||
| 71 | 70 | |
| 72 | 71 | $pdfData = $fpdf->Output('S'); |
| 73 | 72 | |
| 74 | - if ($file !== null) { |
|
| 73 | + if ($file !== null){ |
|
| 75 | 74 | $this->saveToFile($pdfData, $file); |
| 76 | 75 | } |
| 77 | 76 | |