Failed Conditions
Push — master ( a3629e...b4f6c5 )
by Florent
08:47
created

ClientCreatedEvent::create()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 3
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\Client\Event;
15
16
use OAuth2Framework\Component\Core\Client\ClientId;
17
use OAuth2Framework\Component\Core\DataBag\DataBag;
18
use OAuth2Framework\Component\Core\Event\Event;
19
use OAuth2Framework\Component\Core\Id\Id;
20
use OAuth2Framework\Component\Core\UserAccount\UserAccountId;
21
22
class ClientCreatedEvent extends Event
23
{
24
    private $clientId;
25
    private $parameters;
26
    private $userAccountId;
27
28
    public function __construct(ClientId $clientId, DataBag $parameters, ?UserAccountId $userAccountId)
29
    {
30
        $this->clientId = $clientId;
31
        $this->parameters = $parameters;
32
        $this->userAccountId = $userAccountId;
33
    }
34
35
    public static function getSchema(): string
36
    {
37
        return 'https://oauth2-framework.spomky-labs.com/schemas/events/client/created/1.0/schema';
38
    }
39
40
    public function getDomainId(): Id
41
    {
42
        return $this->clientId;
43
    }
44
45
    public function getPayload()
46
    {
47
        return [
48
            'user_account_id' => $this->userAccountId ? $this->userAccountId->getValue() : null,
49
            'parameters' => (object) $this->parameters->all(),
50
        ];
51
    }
52
53
    public function getClientId(): ClientId
54
    {
55
        return $this->clientId;
56
    }
57
58
    public function getParameters(): DataBag
59
    {
60
        return $this->parameters;
61
    }
62
63
    public function getOwnerId(): ?UserAccountId
0 ignored issues
show
Documentation introduced by
The return type could not be reliably inferred; please add a @return annotation.

Our type inference engine in quite powerful, but sometimes the code does not provide enough clues to go by. In these cases we request you to add a @return annotation as described here.

Loading history...
64
    {
65
        return $this->userAccountId;
66
    }
67
}
68