CieloRequestHandler   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 23
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 3
c 1
b 0
f 0
dl 0
loc 23
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A cieloRequestException() 0 21 3
1
<?php
2
3
namespace SMartins\JsonHandler;
4
5
use Cielo\API30\Ecommerce\Request\CieloRequestException;
0 ignored issues
show
Bug introduced by
The type Cielo\API30\Ecommerce\Re...t\CieloRequestException was not found. Maybe you did not declare it correctly or list all dependencies?

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:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
6
7
trait CieloRequestHandler
8
{
9
    public function cieloRequestException(CieloRequestException $e)
10
    {
11
        $errors = [];
12
        $code = $e->getCode();
13
        do {
14
            $cieloError = $e->getCieloError();
15
            $error = [
16
                'status'    => $e->getCode(),
17
                'code'      => $this->getCode('cielo').$cieloError->getCode(),
0 ignored issues
show
Bug introduced by
It seems like getCode() must be provided by classes using this trait. How about adding it as abstract method to this trait? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

17
                'code'      => $this->/** @scrutinizer ignore-call */ getCode('cielo').$cieloError->getCode(),
Loading history...
18
                'source'    => ['pointer' => $e->getFile().':'.$e->getLine()],
19
                'title'     => $e->getMessage(),
20
                'detail'    => $cieloError->getMessage(),
21
            ];
22
            if (! in_array($error, $errors)) {
23
                array_push($errors, $error);
24
            }
25
            $e = $e->getPrevious();
26
        } while (method_exists($e, 'getPrevious'));
27
28
        $this->jsonApiResponse->setStatus($code);
0 ignored issues
show
Bug Best Practice introduced by
The property jsonApiResponse does not exist on SMartins\JsonHandler\CieloRequestHandler. Did you maybe forget to declare it?
Loading history...
29
        $this->jsonApiResponse->setErrors($errors);
30
    }
31
}
32