ProfileInfo::isDemo()   A
last analyzed

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 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