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

AuthenticationHandler   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 AuthenticationHandler extends AbstractHandler
9
{
10
    /**
11
     * {@inheritDoc}
12
     */
13
    public function handle()
14
    {
15
        return (new Error)->setStatus(401)
0 ignored issues
show
Bug Best Practice introduced by
The expression return new SMartins\Exce...uthentication.detail')) 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...
16
            ->setCode($this->getCode('authentication'))
17
            ->setSource((new Source())->setPointer($this->getDefaultPointer()))
18
            ->setTitle($this->getDefaultTitle())
19
            ->setDetail(__('exception::exceptions.authentication.detail'));
20
    }
21
}
22