| Total Complexity | 5 |
| Total Lines | 42 |
| Duplicated Lines | 0 % |
| Coverage | 0% |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 7 | trait TypedClassPrinterTrait |
||
| 8 | { |
||
| 9 | protected string $type; |
||
| 10 | |||
| 11 | protected bool $isDoingTypeMatch = false; |
||
| 12 | |||
| 13 | public function printFromType(): string |
||
| 22 | } |
||
| 23 | |||
| 24 | protected function getSignaturesFromType(): array |
||
| 25 | { |
||
| 26 | $reflection = new ReflectionClass($this->type); |
||
| 27 | $methods = $reflection->getMethods(); |
||
| 28 | $templates = $this->getDefaultSignatures(); |
||
| 29 | |||
| 30 | $signatures = []; |
||
| 31 | |||
| 32 | foreach ($methods as $method) { |
||
| 33 | if ($templates[$method = $method->getName()] ?? false) { |
||
| 34 | $signatures[$method] = $templates[$method]; |
||
| 35 | } |
||
| 36 | } |
||
| 37 | |||
| 38 | return $signatures; |
||
| 39 | } |
||
| 40 | |||
| 41 | protected function isDoingTypeMatch(): bool |
||
| 44 | } |
||
| 45 | |||
| 46 | abstract protected function print(array $methods): string; |
||
| 47 | |||
| 48 | abstract protected function getDefaultSignatures(): array; |
||
| 49 | } |
||
| 50 |