1 | <?php |
||
34 | class Response |
||
35 | { |
||
36 | /** |
||
37 | * Api Version |
||
38 | * |
||
39 | * @var string number of version |
||
40 | */ |
||
41 | private $apiVersion; |
||
42 | |||
43 | /** |
||
44 | * Api Context |
||
45 | * |
||
46 | * @var string name of context |
||
47 | */ |
||
48 | private $context; |
||
49 | |||
50 | /** |
||
51 | * Output Format |
||
52 | * |
||
53 | * @var string json|array|object |
||
54 | */ |
||
55 | private $format; |
||
56 | |||
57 | /** |
||
58 | * Response constructor. |
||
59 | * |
||
60 | * @param string $apiVersion number of version |
||
61 | * @param string $context name of context |
||
62 | * @param string $format json|array|object |
||
63 | */ |
||
64 | public function __construct($apiVersion = '1.0', $context = 'api', $format = 'json') |
||
70 | |||
71 | /** |
||
72 | * Generate error response |
||
73 | * |
||
74 | * @param integer $code number of error |
||
75 | * @param string $msg message to identify error |
||
76 | * @param array $extra extra data |
||
77 | * |
||
78 | * @return array|object|string |
||
79 | */ |
||
80 | 6 | public function error($code, $msg, $extra = []) |
|
97 | |||
98 | /** |
||
99 | * Generate success response |
||
100 | * |
||
101 | * @param array $data data |
||
102 | * |
||
103 | * @return array|object|string |
||
104 | */ |
||
105 | 9 | public function success($data) |
|
114 | |||
115 | /** |
||
116 | * Generate basic structure |
||
117 | * |
||
118 | * This structure is used in all the responses |
||
119 | * |
||
120 | * @return array |
||
121 | */ |
||
122 | 15 | private function basicStructure() |
|
129 | |||
130 | /** |
||
131 | * Generate output |
||
132 | * |
||
133 | * @param array|object $data output data |
||
134 | * |
||
135 | * @return array|object|string |
||
136 | */ |
||
137 | 15 | private function output($data) |
|
150 | } |
||
151 |
This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.
Both the
$myVar
assignment in line 1 and the$higher
assignment in line 2 are dead. The first because$myVar
is never used and the second because$higher
is always overwritten for every possible time line.