| Conditions | 8 |
| Paths | 6 |
| Total Lines | 53 |
| Code Lines | 27 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.
For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.
Commonly applied refactorings include:
If many parameters/temporary variables are present:
| 1 | <?php |
||
| 149 | public function get_json() |
||
| 150 | { |
||
| 151 | $ar = array( |
||
| 152 | 'params' => $this->get_params() |
||
| 153 | ); |
||
| 154 | if (isset($this->data)) |
||
| 155 | { |
||
| 156 | $ar['data'] = $this->data; |
||
| 157 | } |
||
| 158 | if ($this->jwt['using'] === true) |
||
| 159 | { |
||
| 160 | $payload = $ar; |
||
| 161 | $payload['iat'] = $this->get_param_iat(); |
||
| 162 | |||
| 163 | // check private key file |
||
| 164 | if ( ! file_exists($this->jwt['our_privkey'])) |
||
| 165 | { |
||
| 166 | throw new Exception\Runtime('The file with the private key was not find!'); |
||
| 167 | } |
||
| 168 | |||
| 169 | // load private key file |
||
| 170 | $fpkey = fopen($this->jwt['our_privkey'], "rb"); |
||
| 171 | if ($fpkey === FALSE) |
||
| 172 | { |
||
| 173 | throw new Exception\Runtime('The file with the private key was not open!'); |
||
| 174 | } |
||
| 175 | $privateKey = fread($fpkey, 8192); |
||
| 176 | if ($privateKey === FALSE) |
||
| 177 | { |
||
| 178 | throw new Exception\Runtime('The file with the private key was not read!'); |
||
| 179 | } |
||
| 180 | fclose($fpkey); |
||
| 181 | |||
| 182 | try |
||
| 183 | { |
||
| 184 | $token = JWT::encode($payload, $privateKey, 'RS512'); |
||
| 185 | } |
||
| 186 | catch (\Exception $e) |
||
| 187 | { |
||
| 188 | Log::instance()->error($e->getMessage().PHP_EOL.$e->getTraceAsString()); |
||
| 189 | throw new Exception\JSON('unable to create JWT token', $e); |
||
| 190 | } |
||
| 191 | |||
| 192 | if (isset($ar['data'])) unset($ar['data']); |
||
| 193 | |||
| 194 | $ar['token'] = $token; |
||
| 195 | } |
||
| 196 | $json = json_encode($ar, JSON_UNESCAPED_SLASHES); |
||
| 197 | |||
| 198 | Log::instance()->debug('build JSON:'); |
||
| 199 | Log::instance()->debug($json); |
||
| 200 | |||
| 201 | return $json; |
||
| 202 | } |
||
| 233 |
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths