Passed
Push — master ( 825827...ca86ac )
by Samuel
02:38
created

BadRequestHttpHandler::badRequestHttpException()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 14
Code Lines 9

Duplication

Lines 14
Ratio 100 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 14
loc 14
rs 9.4285
cc 1
eloc 9
nc 1
nop 1
1
<?php
2
3
namespace SMartins\JsonHandler;
4
5
use Symfony\Component\HttpKernel\Exception\BadRequestHttpException;
0 ignored issues
show
Bug introduced by
The type Symfony\Component\HttpKe...BadRequestHttpException 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 View Code Duplication
trait BadRequestHttpHandler
0 ignored issues
show
Duplication introduced by
This class seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
8
{
9
    public function badRequestHttpException(BadRequestHttpException $exception)
10
    {
11
        $statusCode = $exception->getStatusCode();
12
13
        $error = [[
14
            'status'    => $statusCode,
15
            'code'      => $this->getCode('bad_request'),
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

15
            'code'      => $this->/** @scrutinizer ignore-call */ getCode('bad_request'),
Loading history...
16
            'source'    => ['pointer' => $exception->getFile().':'.$exception->getLine()],
17
            'title'     => 'bad_request',
18
            'detail'    => $exception->getMessage(),
19
        ]];
20
21
        $this->jsonApiResponse->setStatus($statusCode);
0 ignored issues
show
Bug Best Practice introduced by
The property jsonApiResponse does not exist on SMartins\JsonHandler\BadRequestHttpHandler. Did you maybe forget to declare it?
Loading history...
22
        $this->jsonApiResponse->setErrors($error);
23
    }
24
}
25