Total Complexity | 7 |
Total Lines | 41 |
Duplicated Lines | 0 % |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
26 | trait ErrorsTrait |
||
27 | { |
||
28 | /** |
||
29 | * Check and print errors in API response. Null response object is considered as no errors |
||
30 | * |
||
31 | * @access protected |
||
32 | * @static |
||
33 | * @param object $response |
||
34 | * |
||
35 | * @return void |
||
36 | */ |
||
37 | protected static function printPlainTextErrors(object $response) |
||
38 | { |
||
39 | foreach ($response->errors as $err){ |
||
40 | $text = 'Error: '; |
||
41 | $text .= self::getErrorDetail($err, 'title'); |
||
|
|||
42 | $text .= self::getErrorDetail($err, 'statuts'); |
||
43 | $text .= self::getErrorDetail($err, 'parameter', 'source'); |
||
44 | $text .= self::getErrorDetail($err, 'detail'); |
||
45 | $text .= PHP_EOL; |
||
46 | echo $text; |
||
47 | } |
||
48 | } |
||
49 | |||
50 | /** |
||
51 | * Get error property if exist |
||
52 | * |
||
53 | * @access protected |
||
54 | * @static |
||
55 | * @param object $error |
||
56 | * @param string $field |
||
57 | * |
||
58 | * @return void |
||
59 | */ |
||
60 | private static function getErrorDetail(object $error, string $field, ?string $parent = null) |
||
67 | } |
||
68 | |||
69 | } |
This check looks for function or method calls that always return null and whose return value is used.
The method
getObject()
can return nothing but null, so it makes no sense to use the return value.The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes.