Passed
Push — master ( b38c95...825827 )
by Samuel
01:24
created

MissingScopeHandler::missingScopeException()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 12
Code Lines 8

Duplication

Lines 12
Ratio 100 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 12
loc 12
rs 9.4285
cc 1
eloc 8
nc 1
nop 1
1
<?php
2
3
namespace SMartins\JsonHandler;
4
5
use Laravel\Passport\Exceptions\MissingScopeException;
0 ignored issues
show
Bug introduced by
The type Laravel\Passport\Exceptions\MissingScopeException 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 MissingScopeHandler
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 missingScopeException(MissingScopeException $exception)
10
    {
11
        $error = [[
12
            'status'    => 403,
13
            'code'      => $this->getCode('missing_scope'),
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

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