Passed
Push — master ( 4369e3...b38c95 )
by Samuel
01:47
created

OAuthServerHandler::oAuthServerException()   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
dl 14
loc 14
rs 9.4285
c 1
b 0
f 0
cc 1
eloc 9
nc 1
nop 1
1
<?php
2
3
namespace SMartins\JsonHandler;
4
5
use League\OAuth2\Server\Exception\OAuthServerException;
0 ignored issues
show
Bug introduced by
The type League\OAuth2\Server\Exc...on\OAuthServerException 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 OAuthServerHandler
8
{
9 View Code Duplication
    public function oAuthServerException(OAuthServerException $exception)
0 ignored issues
show
Duplication introduced by
This method 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...
10
    {
11
        $statusCode = $exception->getHttpStatusCode();
12
13
        $error = [[
14
            'status'    => $statusCode,
15
            'code'      => $this->getCode('not_found_http'),
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('not_found_http'),
Loading history...
16
            'source'    => ['pointer' => $exception->getFile().':'.$exception->getLine()],
17
            'title'     => $exception->getErrorType(),
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\OAuthServerHandler. Did you maybe forget to declare it?
Loading history...
22
        $this->jsonApiResponse->setErrors($error);
23
    }
24
}
25