City::getCityName()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 1
c 1
b 0
f 0
dl 0
loc 3
ccs 2
cts 2
cp 1
rs 10
cc 1
nc 1
nop 0
crap 1
1
<?php
2
3
4
namespace talismanfr\psbbank\vo;
5
6
7
use talismanfr\psbbank\vo\traits\Errors;
8
9
class City
10
{
11
    use Errors;
12
13
    /**
14
     * @var int|null
15
     */
16
    private $id;
17
    /** @var string|null */
18
    private $cityId;
19
    /** @var string|null */
20
    private $cityName;
21
    /** @var string|null */
22
    private $cityTimezone;
23
    /** @var string|null */
24
    private $region;
25
26
    /**
27
     * City constructor.
28
     * @param int|null $id
29
     * @param string|null $cityId
30
     * @param string|null $cityName
31
     * @param string|null $cityTimezone
32
     * @param string|null $region
33
     * @param array|null $errors
34
     */
35 1
    public function __construct(?int $id, ?string $cityId, ?string $cityName, ?string $cityTimezone, ?string $region, ?array $errors)
36
    {
37 1
        $this->id = $id;
38 1
        $this->cityId = $cityId;
39 1
        $this->cityName = $cityName;
40 1
        $this->cityTimezone = $cityTimezone;
41 1
        $this->region = $region;
42 1
        $this->errors = $errors;
43 1
    }
44
45
    /**
46
     * @param array $data
47
     * @return self
48
     */
49 1
    public static function fromResponseData(array $data): self
50
    {
51 1
        $errors = self::buildErrors($data);
52 1
        if ($errors) {
53 1
            return new self(null, null, null, null, null, $errors);
54
        }
55
56 1
        return new self(
57 1
            $data['id'],
58 1
            $data["city_id"],
59 1
            $data['city_name'],
60 1
            $data['city_timezone'],
61 1
            $data['region'],
62 1
            null
63
        );
64
    }
65
66
    /**
67
     * @return int|null
68
     */
69 1
    public function getId(): ?int
70
    {
71 1
        return $this->id;
72
    }
73
74
    /**
75
     * @return string|null
76
     */
77 1
    public function getCityId(): ?string
78
    {
79 1
        return $this->cityId;
80
    }
81
82
    /**
83
     * @return string|null
84
     */
85 1
    public function getCityName(): ?string
86
    {
87 1
        return $this->cityName;
88
    }
89
90
    /**
91
     * @return string|null
92
     */
93 1
    public function getCityTimezone(): ?string
94
    {
95 1
        return $this->cityTimezone;
96
    }
97
98
    /**
99
     * @return string|null
100
     */
101 1
    public function getRegion(): ?string
102
    {
103 1
        return $this->region;
104
    }
105
106
107
}