1 | <?php |
||
9 | class ExtensionCollection |
||
10 | { |
||
11 | /** |
||
12 | * @var array collection |
||
13 | */ |
||
14 | protected $collection = ['basic' => [], 'dynamic' => []]; |
||
15 | |||
16 | /** |
||
17 | * @var string $basic_interface |
||
18 | */ |
||
19 | protected $basic_interface = 'League\CLImate\TerminalObject\Basic\BasicTerminalObjectInterface'; |
||
20 | |||
21 | /** |
||
22 | * @var string $dynamic_interface |
||
23 | */ |
||
24 | 36 | protected $dynamic_interface = 'League\CLImate\TerminalObject\Dynamic\DynamicTerminalObjectInterface'; |
|
25 | |||
26 | 36 | public function __construct($key, $class) |
|
30 | |||
31 | 28 | public function collection() |
|
35 | |||
36 | /** |
||
37 | * Create the collection from the key/class |
||
38 | * |
||
39 | * @param string $original_key |
||
40 | * @param string|object|array $original_class |
||
41 | * |
||
42 | 36 | * @return void |
|
43 | */ |
||
44 | 36 | protected function createCollection($original_key, $original_class) |
|
53 | |||
54 | /** |
||
55 | * Convert the given class and key to an array of classes |
||
56 | * |
||
57 | * @param string|object|array $class |
||
58 | * @param string $key Optional custom key instead of class name |
||
59 | * |
||
60 | 36 | * @return array |
|
61 | */ |
||
62 | 36 | protected function convertToArray($key, $class) |
|
70 | |||
71 | /** |
||
72 | * Ensure that the extension is valid |
||
73 | * |
||
74 | 36 | * @param string|object|array $class |
|
75 | */ |
||
76 | 36 | protected function validateExtension($class) |
|
81 | |||
82 | /** |
||
83 | * @param string|object $class |
||
84 | * |
||
85 | 36 | * @throws UnexpectedValueException if extension class does not exist |
|
86 | */ |
||
87 | 36 | protected function validateClassExists($class) |
|
93 | |||
94 | /** |
||
95 | * @param string|object $class |
||
96 | * |
||
97 | 32 | * @throws InvalidArgumentException if extension class does not implement either Dynamic or Basic interface |
|
98 | */ |
||
99 | 32 | protected function validateClassImplementation($class) |
|
111 | |||
112 | /** |
||
113 | * Determine the extension key based on the class |
||
114 | * |
||
115 | * @param string|null $key |
||
116 | * @param string|object $class |
||
117 | * |
||
118 | 36 | * @return string |
|
119 | */ |
||
120 | 36 | protected function getKey($key, $class) |
|
131 | |||
132 | /** |
||
133 | * Get the type of class the extension implements |
||
134 | * |
||
135 | * @param string|object $class |
||
136 | * |
||
137 | 28 | * @return string 'basic' or 'dynamic' |
|
138 | */ |
||
139 | 28 | protected function getType($class) |
|
147 | } |
||
148 |
This check looks at variables that have been passed in as parameters and are passed out again to other methods.
If the outgoing method call has stricter type requirements than the method itself, an issue is raised.
An additional type check may prevent trouble.