@@ -27,21 +27,21 @@ discard block |
||
27 | 27 | const ERROR_COMMAND_DOES_NOT_EXIST = 45902; |
28 | 28 | const ERROR_INVALID_DUMMY_COMMAND_TYPE = 45903; |
29 | 29 | |
30 | - /** |
|
31 | - * @var Mailcode_Commands_Command[] |
|
32 | - */ |
|
30 | + /** |
|
31 | + * @var Mailcode_Commands_Command[] |
|
32 | + */ |
|
33 | 33 | private $commands = array(); |
34 | 34 | |
35 | - /** |
|
36 | - * @var array<string,Mailcode_Commands_Command> |
|
37 | - */ |
|
35 | + /** |
|
36 | + * @var array<string,Mailcode_Commands_Command> |
|
37 | + */ |
|
38 | 38 | private static $dummyCommands = array(); |
39 | 39 | |
40 | - /** |
|
41 | - * Retrieves a list of all available command IDs. |
|
42 | - * |
|
43 | - * @return string[] |
|
44 | - */ |
|
40 | + /** |
|
41 | + * Retrieves a list of all available command IDs. |
|
42 | + * |
|
43 | + * @return string[] |
|
44 | + */ |
|
45 | 45 | public function getIDs() : array |
46 | 46 | { |
47 | 47 | static $ids = array(); |
@@ -87,12 +87,12 @@ discard block |
||
87 | 87 | return $result; |
88 | 88 | } |
89 | 89 | |
90 | - /** |
|
91 | - * Gets an available command by its ID. |
|
92 | - * |
|
93 | - * @param string $id |
|
94 | - * @return Mailcode_Commands_Command |
|
95 | - */ |
|
90 | + /** |
|
91 | + * Gets an available command by its ID. |
|
92 | + * |
|
93 | + * @param string $id |
|
94 | + * @return Mailcode_Commands_Command |
|
95 | + */ |
|
96 | 96 | public function getByID(string $id) : Mailcode_Commands_Command |
97 | 97 | { |
98 | 98 | static $instances = array(); |
@@ -105,15 +105,15 @@ discard block |
||
105 | 105 | return $instances[$id]; |
106 | 106 | } |
107 | 107 | |
108 | - /** |
|
109 | - * Retrieves the ID of a command by its name. |
|
110 | - * |
|
111 | - * @param string $name |
|
112 | - * @throws Mailcode_Exception |
|
113 | - * @return string |
|
114 | - * |
|
115 | - * @see Mailcode_Commands::ERROR_COMMAND_NAME_DOES_NOT_EXIST |
|
116 | - */ |
|
108 | + /** |
|
109 | + * Retrieves the ID of a command by its name. |
|
110 | + * |
|
111 | + * @param string $name |
|
112 | + * @throws Mailcode_Exception |
|
113 | + * @return string |
|
114 | + * |
|
115 | + * @see Mailcode_Commands::ERROR_COMMAND_NAME_DOES_NOT_EXIST |
|
116 | + */ |
|
117 | 117 | public function getIDByName(string $name) : string |
118 | 118 | { |
119 | 119 | $items = $this->getAll(); |
@@ -142,12 +142,12 @@ discard block |
||
142 | 142 | return in_array($id, $ids); |
143 | 143 | } |
144 | 144 | |
145 | - /** |
|
146 | - * Checks wether the specified name exists. |
|
147 | - * |
|
148 | - * @param string $name For example: "showvar". |
|
149 | - * @return bool |
|
150 | - */ |
|
145 | + /** |
|
146 | + * Checks wether the specified name exists. |
|
147 | + * |
|
148 | + * @param string $name For example: "showvar". |
|
149 | + * @return bool |
|
150 | + */ |
|
151 | 151 | public function nameExists(string $name) : bool |
152 | 152 | { |
153 | 153 | $items = $this->getAll(); |
@@ -201,14 +201,14 @@ discard block |
||
201 | 201 | return $class; |
202 | 202 | } |
203 | 203 | |
204 | - /** |
|
205 | - * Translates the command type to the expected class naming scheme. |
|
206 | - * |
|
207 | - * Example: not-empty => NotEmpty |
|
208 | - * |
|
209 | - * @param string $type |
|
210 | - * @return string |
|
211 | - */ |
|
204 | + /** |
|
205 | + * Translates the command type to the expected class naming scheme. |
|
206 | + * |
|
207 | + * Example: not-empty => NotEmpty |
|
208 | + * |
|
209 | + * @param string $type |
|
210 | + * @return string |
|
211 | + */ |
|
212 | 212 | private function adjustTypeName(string $type) : string |
213 | 213 | { |
214 | 214 | $type = str_replace('-', ' ', $type); |
@@ -46,7 +46,7 @@ discard block |
||
46 | 46 | { |
47 | 47 | static $ids = array(); |
48 | 48 | |
49 | - if(empty($ids)) { |
|
49 | + if (empty($ids)) { |
|
50 | 50 | $ids = FileHelper::createFileFinder(__DIR__.'/Commands/Command') |
51 | 51 | ->getPHPClassNames(); |
52 | 52 | } |
@@ -64,7 +64,7 @@ discard block |
||
64 | 64 | */ |
65 | 65 | public function getAll() |
66 | 66 | { |
67 | - if(!empty($this->commands)) { |
|
67 | + if (!empty($this->commands)) { |
|
68 | 68 | return $this->commands; |
69 | 69 | } |
70 | 70 | |
@@ -72,7 +72,7 @@ discard block |
||
72 | 72 | |
73 | 73 | $result = array(); |
74 | 74 | |
75 | - foreach($ids as $id) |
|
75 | + foreach ($ids as $id) |
|
76 | 76 | { |
77 | 77 | $result[] = $this->getDummyCommand($id); |
78 | 78 | } |
@@ -97,7 +97,7 @@ discard block |
||
97 | 97 | { |
98 | 98 | static $instances = array(); |
99 | 99 | |
100 | - if(!isset($instances[$id])) |
|
100 | + if (!isset($instances[$id])) |
|
101 | 101 | { |
102 | 102 | $instances[$id] = $this->createCommand($id, '__dummy', '', ''); |
103 | 103 | } |
@@ -118,9 +118,9 @@ discard block |
||
118 | 118 | { |
119 | 119 | $items = $this->getAll(); |
120 | 120 | |
121 | - foreach($items as $item) |
|
121 | + foreach ($items as $item) |
|
122 | 122 | { |
123 | - if($item->getName() === $name) { |
|
123 | + if ($item->getName() === $name) { |
|
124 | 124 | return $item->getID(); |
125 | 125 | } |
126 | 126 | } |
@@ -152,9 +152,9 @@ discard block |
||
152 | 152 | { |
153 | 153 | $items = $this->getAll(); |
154 | 154 | |
155 | - foreach($items as $item) |
|
155 | + foreach ($items as $item) |
|
156 | 156 | { |
157 | - if($item->getName() === $name) { |
|
157 | + if ($item->getName() === $name) { |
|
158 | 158 | return true; |
159 | 159 | } |
160 | 160 | } |
@@ -166,7 +166,7 @@ discard block |
||
166 | 166 | { |
167 | 167 | $class = $this->resolveClassName($id, $type); |
168 | 168 | |
169 | - if(!class_exists($class)) |
|
169 | + if (!class_exists($class)) |
|
170 | 170 | { |
171 | 171 | throw new Mailcode_Exception( |
172 | 172 | 'No such command', |
@@ -188,9 +188,9 @@ discard block |
||
188 | 188 | |
189 | 189 | $dummy = $this->getDummyCommand($id); |
190 | 190 | |
191 | - if($dummy->supportsType()) |
|
191 | + if ($dummy->supportsType()) |
|
192 | 192 | { |
193 | - if(empty($type)) |
|
193 | + if (empty($type)) |
|
194 | 194 | { |
195 | 195 | $type = $dummy->getDefaultType(); |
196 | 196 | } |
@@ -228,14 +228,14 @@ discard block |
||
228 | 228 | */ |
229 | 229 | private function getDummyCommand(string $id) : Mailcode_Commands_Command |
230 | 230 | { |
231 | - if(isset(self::$dummyCommands[$id])) { |
|
231 | + if (isset(self::$dummyCommands[$id])) { |
|
232 | 232 | return self::$dummyCommands[$id]; |
233 | 233 | } |
234 | 234 | |
235 | 235 | $class = 'Mailcode\Mailcode_Commands_Command_'.$id; |
236 | 236 | $cmd = new $class('__dummy'); |
237 | 237 | |
238 | - if($cmd instanceof Mailcode_Commands_Command) |
|
238 | + if ($cmd instanceof Mailcode_Commands_Command) |
|
239 | 239 | { |
240 | 240 | self::$dummyCommands[$id] = $cmd; |
241 | 241 | return $cmd; |