Failed Conditions
Push — master ( c24b3a...b512e9 )
by Florent
14:42
created

AccessTokenRevokedEvent::create()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 1
1
<?php
2
3
declare(strict_types=1);
4
5
/*
6
 * The MIT License (MIT)
7
 *
8
 * Copyright (c) 2014-2018 Spomky-Labs
9
 *
10
 * This software may be modified and distributed under the terms
11
 * of the MIT license.  See the LICENSE file for details.
12
 */
13
14
namespace OAuth2Framework\Component\Core\AccessToken\Event;
15
16
use OAuth2Framework\Component\Core\AccessToken\AccessTokenId;
17
use OAuth2Framework\Component\Core\Event\Event;
18
use OAuth2Framework\Component\Core\Id\Id;
19
use OAuth2Framework\Component\Core\Domain\DomainObject;
20
21
class AccessTokenRevokedEvent extends Event
22
{
23
    /**
24
     * @var AccessTokenId
25
     */
26
    private $accessTokenId;
27
28
    /**
29
     * AccessTokenRevokedEvent constructor.
30
     *
31
     * @param AccessTokenId $accessTokenId
32
     */
33
    protected function __construct(AccessTokenId $accessTokenId)
34
    {
35
        $this->accessTokenId = $accessTokenId;
36
    }
37
38
    /**
39
     * {@inheritdoc}
40
     */
41
    public static function getSchema(): string
42
    {
43
        return 'https://oauth2-framework.spomky-labs.com/schemas/events/access-token/revoked/1.0/schema';
44
    }
45
46
    /**
47
     * @param AccessTokenId $accessTokenId
48
     *
49
     * @return AccessTokenRevokedEvent
50
     */
51
    public static function create(AccessTokenId $accessTokenId): self
52
    {
53
        return new self($accessTokenId);
54
    }
55
56
    /**
57
     * {@inheritdoc}
58
     */
59
    public static function createFromJson(\stdClass $json): DomainObject
60
    {
61
        $accessTokenId = AccessTokenId::create($json->domain_id);
62
63
        return new self($accessTokenId);
64
    }
65
66
    /**
67
     * @return AccessTokenId
68
     */
69
    public function getAccessTokenId(): AccessTokenId
70
    {
71
        return $this->accessTokenId;
72
    }
73
74
    /**
75
     * {@inheritdoc}
76
     */
77
    public function getDomainId(): Id
78
    {
79
        return $this->getAccessTokenId();
80
    }
81
82
    /**
83
     * {@inheritdoc}
84
     */
85
    public function getPayload()
86
    {
87
    }
88
}
89