Passed
Branch 2.0 (f5ddb0)
by Samuel
04:04
created

OAuthServerHandler   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 12
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
dl 0
loc 12
rs 10
c 0
b 0
f 0
wmc 1

1 Method

Rating   Name   Duplication   Size   Complexity  
A handle() 0 7 1
1
<?php
2
3
namespace SMartins\Exceptions\Handlers;
4
5
use SMartins\Exceptions\JsonApi\Error;
6
use SMartins\Exceptions\JsonApi\Source;
7
8
class OAuthServerHandler extends AbstractHandler
9
{
10
    /**
11
     * {@inheritDoc}
12
     */
13
    public function handle()
14
    {
15
        return (new Error)->setStatus($this->getHttpStatusCode())
0 ignored issues
show
Bug Best Practice introduced by
The expression return new SMartins\Exce...xception->getMessage()) returns the type SMartins\Exceptions\JsonApi\Error which is incompatible with the return type mandated by SMartins\Exceptions\Hand...stractHandler::handle() of array|Illuminate\Support\Collection.

In the issue above, the returned value is violating the contract defined by the mentioned interface.

Let's take a look at an example:

interface HasName {
    /** @return string */
    public function getName();
}

class Name {
    public $name;
}

class User implements HasName {
    /** @return string|Name */
    public function getName() {
        return new Name('foo'); // This is a violation of the ``HasName`` interface
                                // which only allows a string value to be returned.
    }
}
Loading history...
Bug introduced by
The method getHttpStatusCode() does not exist on SMartins\Exceptions\Handlers\OAuthServerHandler. Did you maybe mean getStatusCode()? ( Ignorable by Annotation )

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

15
        return (new Error)->setStatus($this->/** @scrutinizer ignore-call */ getHttpStatusCode())

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
16
            ->setCode($this->getCode())
17
            ->setSource((new Source())->setPointer($this->getDefaultPointer()))
18
            ->setTitle($this->exception->getErrorType())
0 ignored issues
show
Bug introduced by
The method getErrorType() does not exist on Exception. ( Ignorable by Annotation )

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

18
            ->setTitle($this->exception->/** @scrutinizer ignore-call */ getErrorType())

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
19
            ->setDetail($this->exception->getMessage());
20
    }
21
}
22