Completed
Pull Request — master (#1028)
by
unknown
04:01
created

RequestEvent::stopPropagation()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 4
ccs 0
cts 3
cp 0
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
crap 2
1
<?php
2
3
/**
4
 * @author      Alex Bilbie <[email protected]>
5
 * @copyright   Copyright (c) Alex Bilbie
6
 * @license     http://mit-license.org/
7
 *
8
 * @link        https://github.com/thephpleague/oauth2-server
9
 */
10
11
namespace League\OAuth2\Server\Event;
12
13
use Psr\EventDispatcher\StoppableEventInterface;
14
use Psr\Http\Message\ServerRequestInterface;
15
16
class RequestEvent implements StoppableEventInterface
17
{
18
    /**
19
     * @var ServerRequestInterface
20
     */
21
    private $request;
22
23
    /**
24
     * @var bool
25
     */
26
    protected $isPropagationStopped = false;
27
28
    /**
29
     * RequestEvent constructor.
30
     *
31
     * @param ServerRequestInterface $request
32
     */
33 30
    public function __construct(ServerRequestInterface $request)
34
    {
35 30
        $this->request = $request;
36 30
    }
37
38
    public function stopPropagation()
39
    {
40
        $this->isPropagationStopped = true;
41
    }
42
43
    public function isPropagationStopped(): bool
44
    {
45
        return $this->isPropagationStopped;
46
    }
47
48
    /**
49
     * @return ServerRequestInterface
50
     * @codeCoverageIgnore
51
     */
52
    public function getRequest()
53
    {
54
        return $this->request;
55
    }
56
57 13
    public static function clientAuthenticationFailed(ServerRequestInterface $request): self
58
    {
59 13
        return new ClientAuthenticationFailedEvent($request);
60
    }
61
62 15
    public static function accessTokenIssued(ServerRequestInterface $request): self
63
    {
64 15
        return new AccessTokenIssuedEvent($request);
65
    }
66
67 1
    public static function userAuthenticationFailed(ServerRequestInterface $request): self
68
    {
69 1
        return new UserAuthenticationFailedEvent($request);
70
    }
71
72 7
    public static function refreshTokenIssued(ServerRequestInterface $request): self
73
    {
74 7
        return new RefreshTokenIssuedEvent($request);
75
    }
76
77 1
    public static function refreshTokenClientFailed(ServerRequestInterface $request): self
78
    {
79 1
        return new RefreshTokenClientFailedEvent($request);
80
    }
81
}
82