| Conditions | 4 |
| Paths | 4 |
| Total Lines | 22 |
| Code Lines | 16 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 23 | public static function create(object $reader = null): ReaderInterface |
||
| 24 | { |
||
| 25 | switch (true) { |
||
| 26 | case $reader instanceof ReaderInterface: |
||
| 27 | return $reader; |
||
| 28 | |||
| 29 | case $reader instanceof DoctrineReader: |
||
| 30 | return new AnnotationReader($reader); |
||
| 31 | |||
| 32 | case $reader === null: |
||
| 33 | return new SelectiveReader([ |
||
| 34 | new AttributeReader(), |
||
| 35 | new AnnotationReader(), |
||
| 36 | ]); |
||
| 37 | |||
| 38 | default: |
||
| 39 | throw new \InvalidArgumentException( |
||
| 40 | sprintf( |
||
| 41 | 'Argument $reader must be an instance of %s or %s, but %s passed.', |
||
| 42 | ReaderInterface::class, |
||
| 43 | DoctrineReader::class, |
||
| 44 | 'instance of ' . explode("\0", get_class($reader))[0] |
||
| 45 | ) |
||
| 50 |