InvalidCredentialsException   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 21
Duplicated Lines 0 %

Importance

Changes 2
Bugs 0 Features 0
Metric Value
eloc 7
c 2
b 0
f 0
dl 0
loc 21
rs 10
wmc 3

3 Methods

Rating   Name   Duplication   Size   Complexity  
A getUsername() 0 3 1
A withDefaultMessage() 0 3 1
A forUsername() 0 6 1
1
<?php
2
3
namespace Signifly\Janitor\Exceptions;
4
5
use Illuminate\Auth\AuthenticationException;
6
7
class InvalidCredentialsException extends AuthenticationException
8
{
9
    /** @var string */
10
    private $username;
11
12
    public static function forUsername(string $username): self
13
    {
14
        $exception = new static(trans('auth.failed'));
0 ignored issues
show
Bug introduced by
It seems like trans('auth.failed') can also be of type array and array; however, parameter $message of Signifly\Janitor\Excepti...xception::__construct() does only seem to accept string, maybe add an additional type check? ( Ignorable by Annotation )

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

14
        $exception = new static(/** @scrutinizer ignore-type */ trans('auth.failed'));
Loading history...
15
        $exception->username = $username;
16
17
        return $exception;
18
    }
19
20
    public static function withDefaultMessage(): self
21
    {
22
        return new static(trans('auth.failed'));
0 ignored issues
show
Bug introduced by
It seems like trans('auth.failed') can also be of type array and array; however, parameter $message of Signifly\Janitor\Excepti...xception::__construct() does only seem to accept string, maybe add an additional type check? ( Ignorable by Annotation )

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

22
        return new static(/** @scrutinizer ignore-type */ trans('auth.failed'));
Loading history...
23
    }
24
25
    protected function getUsername(): string
26
    {
27
        return $this->username;
28
    }
29
}
30