1 | <?php |
||
11 | class Router |
||
12 | { |
||
13 | use ParserImporter, SettingsImporter, OutputImporter, UtilImporter; |
||
14 | |||
15 | /** |
||
16 | * An instance of the Settings Manager class |
||
17 | * |
||
18 | * @var \League\CLImate\Settings\Manager $settings; |
||
19 | */ |
||
20 | protected $settings; |
||
21 | |||
22 | /** |
||
23 | * An instance of the Dynamic Router class |
||
24 | * |
||
25 | * @var \League\CLImate\TerminalObject\Router\DynamicRouter $dynamic; |
||
26 | */ |
||
27 | protected $dynamic; |
||
28 | |||
29 | /** |
||
30 | * An instance of the Basic Router class |
||
31 | * |
||
32 | * @var \League\CLImate\TerminalObject\Router\BasicRouter $basic; |
||
33 | */ |
||
34 | protected $basic; |
||
35 | |||
36 | 948 | public function __construct(DynamicRouter $dynamic = null, BasicRouter $basic = null) |
|
41 | |||
42 | /** |
||
43 | * Register a custom class with the router |
||
44 | * |
||
45 | * @param string $key |
||
46 | * @param string $class |
||
47 | */ |
||
48 | 36 | public function addExtension($key, $class) |
|
58 | |||
59 | /** |
||
60 | * Check if the name matches an existing terminal object |
||
61 | * |
||
62 | * @param string $name |
||
63 | * |
||
64 | * @return boolean |
||
65 | */ |
||
66 | 580 | public function exists($name) |
|
70 | |||
71 | /** |
||
72 | * Execute a terminal object using given arguments |
||
73 | * |
||
74 | * @param string $name |
||
75 | * @param mixed $arguments |
||
76 | * |
||
77 | * @return null|\League\CLImate\TerminalObject\Basic\BasicTerminalObjectInterface |
||
78 | */ |
||
79 | 568 | public function execute($name, $arguments) |
|
101 | |||
102 | /** |
||
103 | * Get the object whether it's a string or already instantiated |
||
104 | * |
||
105 | * @param \League\CLImate\TerminalObject\Router\RouterInterface $router |
||
106 | * @param string $name |
||
107 | * @param array $arguments |
||
108 | * |
||
109 | * @return \League\CLImate\TerminalObject\Dynamic\DynamicTerminalObjectInterface|\League\CLImate\TerminalObject\Basic\BasicTerminalObjectInterface |
||
110 | */ |
||
111 | 568 | protected function getObject($router, $name, $arguments) |
|
125 | |||
126 | /** |
||
127 | * Determine which type of router we are using and return it |
||
128 | * |
||
129 | * @param string $name |
||
130 | * |
||
131 | * @return \League\CLImate\TerminalObject\Router\RouterInterface|null |
||
132 | */ |
||
133 | 568 | protected function getRouter($name) |
|
143 | |||
144 | /** |
||
145 | * Set the settings property |
||
146 | * |
||
147 | * @param \League\CLImate\Settings\Manager $settings |
||
148 | * |
||
149 | * @return Router |
||
150 | */ |
||
151 | 568 | public function settings(Manager $settings) |
|
157 | } |
||
158 |
If a method or function can return multiple different values and unless you are sure that you only can receive a single value in this context, we recommend to add an additional type check:
If this a common case that PHP Analyzer should handle natively, please let us know by opening an issue.