| Conditions | 2 |
| Paths | 1 |
| Total Lines | 15 |
| Code Lines | 7 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 6 |
| CRAP Score | 2 |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 19 | 16 | public function create(string $filepath, ?string $version = null, ?string $encoding = null, ?int $flags = null): Reader |
|
| 20 | { |
||
| 21 | 16 | $xmlReader = $this->readerFactory->create(); |
|
| 22 | 16 | $document = $this->documentFactory->create($version, $encoding); |
|
| 23 | |||
| 24 | 16 | Handler::withErrorHandlerForXMLReader(static function () use ($xmlReader, $filepath, $encoding, $flags): void { |
|
| 25 | 16 | $opened = $xmlReader->open($filepath, $encoding, $flags ?? 0); |
|
| 26 | // @codeCoverageIgnoreStart |
||
| 27 | if ($opened === false) { |
||
| 28 | throw new Exception('\XMLReader::open() method failed'); |
||
| 29 | } |
||
| 30 | // @codeCoverageIgnoreEnd |
||
| 31 | }); |
||
| 32 | |||
| 33 | 14 | return new DefaultReader($xmlReader, $document); |
|
| 34 | } |
||
| 36 |