Completed
Pull Request — master (#4)
by Matthew
01:53
created

InvalidException   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 41
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Test Coverage

Coverage 100%

Importance

Changes 2
Bugs 0 Features 1
Metric Value
wmc 5
c 2
b 0
f 1
lcom 1
cbo 1
dl 0
loc 41
ccs 19
cts 19
cp 1
rs 10

5 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 6 1
A tokenExpired() 0 7 1
A tokenUnparseable() 0 7 1
A invalidSignature() 0 7 1
A invalidToken() 0 7 1
1
<?php
2
namespace Equip\Auth\Exception;
3
4
/**
5
 * Exception that occurs when a user specifies an authentication token that is
6
 * invalid.
7
 */
8
class InvalidException extends AuthException
9
{
10 6
    public function __construct(
11
        $message = 'The token being used is invalid',
12
        \Exception $previous = null
13
    ) {
14 6
        parent::__construct($message, 403, $previous);
15 6
    }
16
17 1
    public static function tokenExpired($token, \Exception $previous = null)
18
    {
19 1
        throw new static(
20 1
            sprintf('Token expired: %s', $token),
21
            $previous
22 1
        );
23
    }
24
25 1
    public static function tokenUnparseable($token, \Exception $previous = null)
26
    {
27 1
        throw new static(
28 1
            sprintf('Could not parse token: %s', $token),
29
            $previous
30 1
        );
31
    }
32
33 1
    public static function invalidSignature($token, \Exception $previous = null)
34
    {
35 1
        throw new static(
36 1
            sprintf('Token signature is not valid: %s', $token),
37
            $previous
38 1
        );
39
    }
40
41 1
    public static function invalidToken($token, \Exception $previous = null)
42
    {
43 1
        throw new static(
44 1
            sprintf('Token is expired or otherwise invalid: %s', $token),
45
            $previous
46 1
        );
47
    }
48
}
49