| Conditions | 2 |
| Paths | 2 |
| Total Lines | 19 |
| Code Lines | 10 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 16 | public function writeFile(string $path): void |
||
| 17 | { |
||
| 18 | $extension = strtolower(pathinfo($path, PATHINFO_EXTENSION)); |
||
| 19 | |||
| 20 | if (!in_array($extension, self::SUPPORTED_EXTENSIONS)) { |
||
| 21 | throw new UnsupportedFileExtensionException(sprintf( |
||
| 22 | 'Your file cannot be saved. Only these file extensions are supported: %s', |
||
| 23 | implode(', ', self::SUPPORTED_EXTENSIONS) |
||
| 24 | )); |
||
| 25 | } |
||
| 26 | |||
| 27 | // This block becomes obsolete when the following pull request gets merged: |
||
| 28 | // https://github.com/endroid/qr-code/pull/191 |
||
| 29 | $writerRegistry = new WriterRegistry(); |
||
| 30 | $writerRegistry->loadDefaultWriters(); |
||
| 31 | $this->setWriterRegistry($writerRegistry); |
||
| 32 | |||
| 33 | $this->setWriterByExtension($extension); |
||
| 34 | parent::writeFile($path); |
||
| 35 | } |
||
| 36 | } |