Failed Conditions
Push — master ( 7c3864...930f9b )
by Florent
14:15
created

UserAccount::getUserAccountId()   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 0
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\ServerBundle\Tests\TestBundle\Entity;
15
16
use OAuth2Framework\Component\Core\ResourceOwner\ResourceOwnerId;
17
use OAuth2Framework\Component\Core\UserAccount\UserAccount as UserAccountInterface;
18
use OAuth2Framework\Component\Core\UserAccount\UserAccountId;
19
20
class UserAccount implements UserAccountInterface
21
{
22
    private $userAccountId;
23
    private $data = [];
24
25
    public function __construct(UserAccountId $userAccountId, array $data)
26
    {
27
        $this->userAccountId = $userAccountId;
28
        $this->data = $data;
29
    }
30
31
    public function getUserAccountId(): UserAccountId
32
    {
33
        return $this->userAccountId;
34
    }
35
36
    public function getPublicId(): ResourceOwnerId
37
    {
38
        return $this->userAccountId;
39
    }
40
41
    public function has(string $key): bool
42
    {
43
        return array_key_exists($key, $this->data);
44
    }
45
46
    public function get(string $key)
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...
47
    {
48
        if (!$this->has($key)) {
49
            throw new \InvalidArgumentException(\Safe\sprintf('The user account parameter "%s" does not exist.', $key));
50
        }
51
52
        return $this->data[$key];
53
    }
54
}
55