PassportCheck::code()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 0
dl 0
loc 3
rs 10
c 0
b 0
f 0
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Damax\Services\Client;
6
7
final class PassportCheck
8
{
9
    private const PASSED = 1;
10
    private const FAILED = 2;
11
    private const MALFORMED = 3;
12
13
    private $data;
14
15
    public static function fromArray(array $data): self
16
    {
17
        return new self($data);
18
    }
19
20
    public function source(): string
21
    {
22
        return $this->data['source'];
23
    }
24
25
    public function code(): int
26
    {
27
        return $this->data['code'];
28
    }
29
30
    public function passed(): bool
31
    {
32
        return self::PASSED === $this->code();
33
    }
34
35
    public function failed(): bool
36
    {
37
        return self::FAILED === $this->code();
38
    }
39
40
    public function malformed(): bool
41
    {
42
        return self::MALFORMED === $this->code();
43
    }
44
45
    public function message(): string
46
    {
47
        return $this->data['message'];
48
    }
49
50
    public function series(): ?string
51
    {
52
        return $this->data['series'] ?? null;
53
    }
54
55
    public function number(): ?string
56
    {
57
        return $this->data['number'] ?? null;
58
    }
59
60
    public function toArray(): array
61
    {
62
        return $this->data;
63
    }
64
65
    private function __construct(array $data)
66
    {
67
        $this->data = $data;
68
    }
69
}
70