Completed
Pull Request — master (#32)
by Yann
03:30
created

TokenExpiredException::create()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 11

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 7
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 11
c 0
b 0
f 0
ccs 7
cts 7
cp 1
rs 9.9
cc 1
nc 1
nop 3
crap 1
1
<?php
2
3
namespace Yokai\SecurityTokenBundle\Exception;
4
5
use DateTime;
6
7
/**
8
 * Exception thrown when token is fetched, but expired.
9
 *
10
 * @author Yann Eugoné <[email protected]>
11
 */
12
class TokenExpiredException extends InvalidTokenException
13
{
14
    /**
15
     * Create an instance of this class.
16
     *
17
     * @param string   $value   The token value
18
     * @param string   $purpose The token purpose
19
     * @param DateTime $date    The token expiration date
20
     *
21
     * @return TokenExpiredException
0 ignored issues
show
Documentation introduced by
Should the return type not be \self?

This check compares the return type specified in the @return annotation of a function or method doc comment with the types returned by the function and raises an issue if they mismatch.

Loading history...
22
     */
23 2
    public static function create(string $value, string $purpose, DateTime $date): self
24
    {
25 2
        return new self(
26 2
            sprintf(
27 2
                'The "%s" token with value "%s" is expired since "%s".',
28 2
                $purpose,
29 2
                $value,
30 2
                $date->format(DateTime::ISO8601)
31
            )
32
        );
33
    }
34
}
35