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