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 | 78 | public function isAssistedBy(string $assistant): bool |
|
21 | } |
||
22 | |||
23 | 91 | public function assistants(): array |
|
24 | { |
||
25 | 91 | $assistants = []; |
|
26 | |||
27 | 91 | foreach ($this->assistants as $assistant) { |
|
28 | 67 | $assistants[] = $this->assistant($assistant); |
|
29 | } |
||
30 | |||
31 | 91 | return $assistants; |
|
32 | } |
||
33 | |||
34 | /** |
||
35 | * Instantiate the assistant |
||
36 | * |
||
37 | * @param string $assistant |
||
38 | * @return Assistant |
||
39 | * @throws \Exception |
||
40 | */ |
||
41 | 76 | public function assistant(string $assistant): Assistant |
|
42 | { |
||
43 | 76 | if (! $this->isAssistedBy($assistant)) { |
|
44 | 1 | throw new MissingAssistant('No assistant [' . $assistant . '] present on manager ' . get_class($this)); |
|
45 | } |
||
46 | |||
47 | 75 | $instance = app($this->getAssistantClass($assistant)); |
|
48 | 75 | $instance->manager($this); |
|
|
|||
49 | |||
50 | 75 | return $instance; |
|
51 | } |
||
52 | |||
53 | 78 | 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.