| Total Complexity | 2 |
| Total Lines | 34 |
| Duplicated Lines | 0 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 9 | trait ClassResolverExceptionTrait |
||
| 10 | { |
||
| 11 | /** |
||
| 12 | * @param object|class-string $caller |
||
|
|
|||
| 13 | */ |
||
| 14 | private function buildMessage(object|string $caller, string $resolvableType): string |
||
| 15 | { |
||
| 16 | $callerClassInfo = ClassInfo::from($caller, $resolvableType); |
||
| 17 | |||
| 18 | $message = 'ClassResolver Exception' . PHP_EOL; |
||
| 19 | $message .= sprintf( |
||
| 20 | 'Cannot resolve the `%s` for your module `%s`', |
||
| 21 | $resolvableType, |
||
| 22 | $callerClassInfo->getModuleName(), |
||
| 23 | ) . PHP_EOL; |
||
| 24 | |||
| 25 | $message .= sprintf( |
||
| 26 | 'You can fix this by adding the missing `%s` to your module.', |
||
| 27 | $resolvableType, |
||
| 28 | ) . PHP_EOL; |
||
| 29 | |||
| 30 | return $message . (sprintf( |
||
| 31 | 'E.g. `%s`', |
||
| 32 | $this->findClassNameExample($callerClassInfo, $resolvableType), |
||
| 33 | ) . PHP_EOL); |
||
| 34 | } |
||
| 35 | |||
| 36 | private function findClassNameExample(ClassInfo $classInfo, string $resolvableType): string |
||
| 43 | ); |
||
| 44 | } |
||
| 46 |