ProfileInfo   A
last analyzed

Complexity

Total Complexity 6

Size/Duplication

Total Lines 64
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 18
c 1
b 0
f 0
dl 0
loc 64
ccs 20
cts 20
cp 1
rs 10
wmc 6

6 Methods

Rating   Name   Duplication   Size   Complexity  
A getName() 0 2 1
A isLegacy() 0 2 1
A createFromResponse() 0 6 1
A getId() 0 2 1
A isDemo() 0 2 1
A __construct() 0 5 1
1
<?php
2
declare(strict_types=1);
3
4
namespace Ely\Mojang\Response;
5
6
class ProfileInfo {
7
8
    /**
9
     * @var string
10
     */
11
    private $id;
12
13
    /**
14
     * @var string
15
     */
16
    private $name;
17
18
    /**
19
     * @var bool
20
     */
21
    private $isLegacy;
22
23
    /**
24
     * @var bool
25
     */
26
    private $isDemo;
27
28 6
    public function __construct(string $id, string $name, bool $isLegacy = false, bool $isDemo = false) {
29 6
        $this->id = $id;
30 6
        $this->name = $name;
31 6
        $this->isLegacy = $isLegacy;
32 6
        $this->isDemo = $isDemo;
33 6
    }
34
35 6
    public static function createFromResponse(array $response): self {
36 6
        return new static(
37 6
            $response['id'],
38 6
            $response['name'],
39 6
            $response['legacy'] ?? false,
40 6
            $response['demo'] ?? false
41
        );
42
    }
43
44
    /**
45
     * @return string user's uuid without dashes
46
     */
47 5
    public function getId(): string {
48 5
        return $this->id;
49
    }
50
51
    /**
52
     * @return string username at the current time
53
     */
54 4
    public function getName(): string {
55 4
        return $this->name;
56
    }
57
58
    /**
59
     * @return bool true means, that account not migrated into Mojang account
60
     */
61 4
    public function isLegacy(): bool {
62 4
        return $this->isLegacy;
63
    }
64
65
    /**
66
     * @return bool true means, that account now in demo mode (not premium user)
67
     */
68 4
    public function isDemo(): bool {
69 4
        return $this->isDemo;
70
    }
71
72
}
73