Conditions | 4 |
Paths | 6 |
Total Lines | 27 |
Code Lines | 13 |
Lines | 0 |
Ratio | 0 % |
Changes | 0 |
1 | <?php |
||
19 | public function run(array $args = []) |
||
20 | { |
||
21 | $method = Yii::$app->request->method; |
||
22 | $method = strtolower($method); |
||
23 | |||
24 | $reflect = new ReflectionClass(get_called_class()); |
||
25 | $props = $reflect->getProperties(ReflectionProperty::IS_PUBLIC); |
||
26 | |||
27 | foreach ($props as $prop) { |
||
28 | $name = $prop->name; |
||
29 | if (in_array($name, ['id', 'controller'])) { |
||
30 | break; |
||
31 | } |
||
32 | |||
33 | $args['class'][$name] = $this->$name; |
||
34 | } |
||
35 | |||
36 | // Make sure the method exists before trying to call it |
||
37 | if (method_exists(get_called_class(), $method)) { |
||
38 | return static::$method($args); |
||
39 | } |
||
40 | |||
41 | // Return a 405 if the method isn't implemented |
||
42 | // When coupled with RestController, this should _never_ get called |
||
43 | // But this is the correct response if for some reason it isn't |
||
44 | throw new HttpException(405); |
||
45 | } |
||
46 | |||
52 | } |
This check looks from parameters that have been defined for a function or method, but which are not used in the method body.