Completed
Push — master ( 8e3fe7...23d229 )
by Matthew
02:24
created

InvalidException   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 56
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 4
c 1
b 0
f 0
lcom 1
cbo 1
dl 0
loc 56
ccs 20
cts 20
cp 1
rs 10

4 Methods

Rating   Name   Duplication   Size   Complexity  
A tokenExpired() 0 8 1
A tokenUnparseable() 0 8 1
A invalidSignature() 0 8 1
A invalidToken() 0 8 1
1
<?php
2
namespace Equip\Auth\Exception;
3
4
use Exception;
5
6
/**
7
 * Exception that occurs when a user specifies an authentication token that is
8
 * invalid.
9
 */
10
class InvalidException extends AuthException
11
{
12
    const CODE = 403;
13
14
    /**
15
     * @param string $token
16
     * @param Exception $previous
17
     */
18 2
    public static function tokenExpired($token, Exception $previous = null)
19
    {
20 2
        return new static(
21 2
            sprintf('Provided auth token `%s` is expired', $token),
22 2
            static::CODE,
23
            $previous
24 2
        );
25
    }
26
27
    /**
28
     * @param string $token
29
     * @param Exception $previous
30
     */
31 2
    public static function tokenUnparseable($token, Exception $previous = null)
32
    {
33 2
        return new static(
34 2
            sprintf('Provided auth token `%s` could not be parsed', $token),
35 2
            static::CODE,
36
            $previous
37 2
        );
38
    }
39
40
    /**
41
     * @param string $token
42
     * @param Exception $previous
43
     */
44 2
    public static function invalidSignature($token, Exception $previous = null)
45
    {
46 2
        return new static(
47 2
            sprintf('Signature of provided auth token `%s` is not valid', $token),
48 2
            static::CODE,
49
            $previous
50 2
        );
51
    }
52
53
    /**
54
     * @param string $token
55
     * @param Exception $previous
56
     */
57 2
    public static function invalidToken($token, Exception $previous = null)
58
    {
59 2
        return new static(
60 2
            sprintf('Provided auth token `%s` is expired or otherwise invalid', $token),
61 2
            static::CODE,
62
            $previous
63 2
        );
64
    }
65
}
66