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

InvalidException::invalidSignature()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 7
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 1
Metric Value
c 1
b 0
f 1
dl 0
loc 7
ccs 4
cts 4
cp 1
rs 9.4285
cc 1
eloc 4
nc 1
nop 2
crap 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