Passed
Push — master ( cf4a17...0b0ca2 )
by
01:59
created

ApiStatus::isRed()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 2
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 0
dl 0
loc 2
rs 10
c 0
b 0
f 0
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
    public function __construct(string $serviceName, string $status) {
19
        $this->serviceName = $serviceName;
20
        $this->status = $status;
21
    }
22
23
    public function getServiceName(): string {
24
        return $this->serviceName;
25
    }
26
27
    public function getStatus(): string {
28
        return $this->status;
29
    }
30
31
    /**
32
     * Asserts that current service has no issues.
33
     *
34
     * @return bool
35
     */
36
    public function isGreen(): bool {
37
        return $this->assertStatusIs('green');
38
    }
39
40
    /**
41
     * Asserts that current service has some issues.
42
     *
43
     * @return bool
44
     */
45
    public function isYellow(): bool {
46
        return $this->assertStatusIs('yellow');
47
    }
48
49
    /**
50
     * Asserts that current service is unavailable.
51
     *
52
     * @return bool
53
     */
54
    public function isRed(): bool {
55
        return $this->assertStatusIs('red');
56
    }
57
58
    private function assertStatusIs(string $expectedStatus): bool {
59
        return $this->getStatus() === $expectedStatus;
60
    }
61
62
}
63