| @@ 104-122 (lines=19) @@ | ||
| 101 | * @return string[] |
|
| 102 | * An associative array of commands and their handler methods. |
|
| 103 | */ |
|
| 104 | private function getCommandHandlers() |
|
| 105 | { |
|
| 106 | $commands = []; |
|
| 107 | ||
| 108 | foreach (get_class_methods($this) as $method) { |
|
| 109 | $matches = []; |
|
| 110 | if (preg_match('/^handle(.+)$/', $method, $matches)) { |
|
| 111 | $command = $matches[1]; |
|
| 112 | $classNameMethod = 'get' . $command . 'ClassName'; |
|
| 113 | ||
| 114 | if (method_exists($this, $classNameMethod)) { |
|
| 115 | $commandFullClassName = call_user_func(array($this, $classNameMethod)); |
|
| 116 | $commands[$commandFullClassName] = $method; |
|
| 117 | } |
|
| 118 | } |
|
| 119 | } |
|
| 120 | ||
| 121 | return $commands; |
|
| 122 | } |
|
| 123 | ||
| 124 | /** |
|
| 125 | * @return string |
|
| @@ 167-186 (lines=20) @@ | ||
| 164 | * @return string[] |
|
| 165 | * An associative array of commands and their handler methods. |
|
| 166 | */ |
|
| 167 | private function getEventHandlers() |
|
| 168 | { |
|
| 169 | $events = []; |
|
| 170 | ||
| 171 | foreach (get_class_methods($this) as $method) { |
|
| 172 | $matches = []; |
|
| 173 | ||
| 174 | if (preg_match('/^apply(.+)$/', $method, $matches)) { |
|
| 175 | $event = $matches[1]; |
|
| 176 | $classNameMethod = 'get' . $event . 'ClassName'; |
|
| 177 | ||
| 178 | if (method_exists($this, $classNameMethod)) { |
|
| 179 | $eventFullClassName = call_user_func(array($this, $classNameMethod)); |
|
| 180 | $events[$eventFullClassName] = $method; |
|
| 181 | } |
|
| 182 | } |
|
| 183 | } |
|
| 184 | ||
| 185 | return $events; |
|
| 186 | } |
|
| 187 | ||
| 188 | /** |
|
| 189 | * @return string |
|