Passed
Push — master ( bbc85b...f0bc06 )
by
04:59
created

AuthenticateResponse::getSelectedProfile()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 2
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 1
c 1
b 0
f 0
nc 1
nop 0
dl 0
loc 2
ccs 2
cts 2
cp 1
crap 1
rs 10
1
<?php
2
declare(strict_types=1);
3
4
namespace Ely\Mojang\Response;
5
6
class AuthenticateResponse {
7
8
    /**
9
     * @var string
10
     */
11
    private $accessToken;
12
13
    /**
14
     * @var string
15
     */
16
    private $clientToken;
17
18
    /**
19
     * @var array
20
     */
21
    private $rawAvailableProfiles;
22
23
    /**
24
     * @var array
25
     */
26
    private $rawSelectedProfile;
27
28
    /**
29
     * @var array
30
     */
31
    private $rawUser;
32
33 3
    public function __construct(
34
        string $accessToken,
35
        string $clientToken,
36
        array $availableProfiles,
37
        array $selectedProfile,
38
        array $user
39
    ) {
40 3
        $this->accessToken = $accessToken;
41 3
        $this->clientToken = $clientToken;
42 3
        $this->rawAvailableProfiles = $availableProfiles;
43 3
        $this->rawSelectedProfile = $selectedProfile;
44 3
        $this->rawUser = $user;
45 3
    }
46
47 2
    public function getAccessToken(): string {
48 2
        return $this->accessToken;
49
    }
50
51 2
    public function getClientToken(): string {
52 2
        return $this->clientToken;
53
    }
54
55
    /**
56
     * @return ProfileInfo[]
57
     */
58 1
    public function getAvailableProfiles(): array {
59 1
        return array_map([ProfileInfo::class, 'createFromResponse'], $this->rawAvailableProfiles);
60
    }
61
62 2
    public function getSelectedProfile(): ProfileInfo {
63 2
        return ProfileInfo::createFromResponse($this->rawSelectedProfile);
64
    }
65
66 2
    public function getUser(): AuthenticationResponseUserField {
67 2
        return new AuthenticationResponseUserField($this->rawUser['id'], $this->rawUser['properties']);
68
    }
69
70
}
71