ApiStatus::isYellow()   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 ApiStatus {
7
8
    /**
9
     * @var string
10
     */
11
    private $serviceName;
12
13
    /**
14
     * @var string
15
     */
16
    private $status;
17
18 5
    public function __construct(string $serviceName, string $status) {
19 5
        $this->serviceName = $serviceName;
20 5
        $this->status = $status;
21 5
    }
22
23 2
    public function getServiceName(): string {
24 2
        return $this->serviceName;
25
    }
26
27 5
    public function getStatus(): string {
28 5
        return $this->status;
29
    }
30
31
    /**
32
     * Asserts that current service has no issues.
33
     *
34
     * @return bool
35
     */
36 3
    public function isGreen(): bool {
37 3
        return $this->assertStatusIs('green');
38
    }
39
40
    /**
41
     * Asserts that current service has some issues.
42
     *
43
     * @return bool
44
     */
45 3
    public function isYellow(): bool {
46 3
        return $this->assertStatusIs('yellow');
47
    }
48
49
    /**
50
     * Asserts that current service is unavailable.
51
     *
52
     * @return bool
53
     */
54 3
    public function isRed(): bool {
55 3
        return $this->assertStatusIs('red');
56
    }
57
58 3
    private function assertStatusIs(string $expectedStatus): bool {
59 3
        return $this->getStatus() === $expectedStatus;
60
    }
61
62
}
63