| Total Complexity | 9 |
| Total Lines | 58 |
| Duplicated Lines | 0 % |
| Coverage | 100% |
| Changes | 0 | ||
| 1 | <?php |
||
| 8 | trait AssistedManager |
||
| 9 | { |
||
| 10 | protected $assistants = []; |
||
| 11 | |||
| 12 | /** |
||
| 13 | * Check if this manager is assisted by a certain assistant |
||
| 14 | * |
||
| 15 | * @param string $assistant |
||
| 16 | * @return bool |
||
| 17 | */ |
||
| 18 | 92 | public function isAssistedBy(string $assistant): bool |
|
| 21 | } |
||
| 22 | |||
| 23 | 101 | public function assistants(): array |
|
| 24 | { |
||
| 25 | 101 | $assistants = []; |
|
| 26 | |||
| 27 | 101 | foreach ($this->assistants as $assistant) { |
|
| 28 | 77 | $assistants[] = $this->assistant($assistant); |
|
| 29 | } |
||
| 30 | |||
| 31 | 101 | return $assistants; |
|
| 32 | } |
||
| 33 | |||
| 34 | /** |
||
| 35 | * Instantiate the assistant |
||
| 36 | * |
||
| 37 | * @param string $assistant |
||
| 38 | * @return Assistant |
||
| 39 | * @throws \Exception |
||
| 40 | */ |
||
| 41 | 90 | public function assistant(string $assistant): Assistant |
|
| 42 | { |
||
| 43 | 90 | if (! $this->isAssistedBy($assistant)) { |
|
| 44 | 1 | throw new MissingAssistant('No assistant [' . $assistant . '] present on manager ' . get_class($this)); |
|
| 45 | } |
||
| 46 | |||
| 47 | 89 | $instance = app($this->getAssistantClass($assistant)); |
|
| 48 | 89 | $instance->manager($this); |
|
|
|
|||
| 49 | |||
| 50 | 89 | return $instance; |
|
| 51 | } |
||
| 52 | |||
| 53 | 92 | private function getAssistantClass($assistant): ?string |
|
| 66 | } |
||
| 67 | } |
||
| 68 |
This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.
This is most likely a typographical error or the method has been renamed.