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