Conditions | 4 |
Paths | 4 |
Total Lines | 18 |
Code Lines | 10 |
Lines | 0 |
Ratio | 0 % |
Changes | 2 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
24 | public function __construct(\ReflectionParameter $param, $value) |
||
25 | { |
||
26 | if(is_array($value)) { |
||
27 | $data = $value; |
||
28 | } else { |
||
29 | if(!is_string($value)) { |
||
30 | throw new Exception\InvalidArgument('Parameter '.$param->name.' expects a json string. ' . gettype($value).' given.'); |
||
31 | } |
||
32 | |||
33 | $data = json_decode($value); |
||
34 | |||
35 | if($data === null) { |
||
36 | throw new Exception\InvalidArgument('Parameter '.$param->name.' expects a valid json string. ' . json_last_error_msg()); |
||
37 | } |
||
38 | } |
||
39 | |||
40 | return call_user_func_array(array('parent', __FUNCTION__), [$data]); |
||
41 | } |
||
42 | } |
||
43 |
Adding a
@return
annotation to a constructor is not recommended, since a constructor does not have a meaningful return value.Please refer to the PHP core documentation on constructors.