| Conditions | 6 |
| Paths | 9 |
| Total Lines | 33 |
| Code Lines | 17 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 9 |
| CRAP Score | 6.0359 |
| Changes | 2 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 11 | 27 | public function getClassFromMethod(string $docBlock, string $method): string |
|
| 12 | 1 | { |
|
| 13 | if ($docBlock === '') { |
||
| 14 | return ''; |
||
| 15 | 26 | } |
|
| 16 | |||
| 17 | if (strcasecmp(substr(PHP_OS, 0, 3), 'WIN') === 0) { |
||
| 18 | $docBlock = str_replace("\n", PHP_EOL, $docBlock); |
||
| 19 | 26 | } |
|
| 20 | 26 | ||
| 21 | 26 | $lines = array_filter( |
|
| 22 | 26 | explode(PHP_EOL, $docBlock), |
|
| 23 | static fn (string $l): bool => str_contains($l, $method), |
||
| 24 | 26 | ); |
|
| 25 | |||
| 26 | 26 | /** @var array<int, string> $lineSplit */ |
|
| 27 | $lineSplit = explode(' ', (string)reset($lines)); |
||
| 28 | |||
| 29 | $classFromMethod = $lineSplit[3] ?? ''; |
||
| 30 | if ($classFromMethod !== '') { |
||
| 31 | return $classFromMethod; |
||
| 32 | } |
||
| 33 | |||
| 34 | if ($method === 'getFactory') { |
||
| 35 | $factoryType = $this->parseFacadeTemplate($docBlock); |
||
| 36 | if ($factoryType !== '') { |
||
| 37 | return $factoryType; |
||
| 38 | } |
||
| 39 | |||
| 40 | return AbstractFactory::class; |
||
| 41 | } |
||
| 42 | |||
| 43 | return ''; |
||
| 44 | } |
||
| 55 |