Completed
Push — master ( 37d52e...ca4941 )
by Jhao
11:04
created

NormalizedAddress::getRoom()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 1
c 0
b 0
f 0
dl 0
loc 3
rs 10
cc 1
nc 1
nop 0
1
<?php
2
3
/**
4
 * This file is part of RussianPost SDK package.
5
 *
6
 * © Appwilio (http://appwilio.com), JhaoDa (https://github.com/jhaoda)
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
declare(strict_types=1);
13
14
namespace Appwilio\RussianPostSDK\Dispatching\Endpoints\Services\Entities;
15
16
use Appwilio\RussianPostSDK\Dispatching\DataAware;
17
use Appwilio\RussianPostSDK\Dispatching\Contracts\Arrayable;
18
19
final class NormalizedAddress implements Arrayable
20
{
21
    use DataAware;
22
23
    /**
24
     * Коды качества нормализации адреса.
25
     *
26
     * @see https://otpravka.pochta.ru/specification#/enums-clean-address-quality
27
     */
28
    public const QUALITY_GOOD = 'GOOD';
29
    public const QUALITY_ON_DEMAND = 'ON_DEMAND';
30
    public const QUALITY_POSTAL_BOX = 'POSTAL_BOX';
31
    public const QUALITY_UNDEF_01 = 'UNDEF_01';
32
    public const QUALITY_UNDEF_02 = 'UNDEF_02';
33
    public const QUALITY_UNDEF_03 = 'UNDEF_03';
34
    public const QUALITY_UNDEF_04 = 'UNDEF_04';
35
    public const QUALITY_UNDEF_05 = 'UNDEF_05';
36
    public const QUALITY_UNDEF_06 = 'UNDEF_06';
37
    public const QUALITY_UNDEF_07 = 'UNDEF_07';
38
39
    /**
40
     * Коды проверки нормализации адреса.
41
     *
42
     * @https://otpravka.pochta.ru/specification#/enums-clean-address-validation
43
     */
44
    public const VALIDATION_VALIDATED = 'VALIDATED';
45
    public const VALIDATION_OVERRIDDEN = 'OVERRIDDEN';
46
    public const VALIDATION_CONFIRMED_MANUALLY = 'CONFIRMED_MANUALLY';
47
48
    public function getId(): string
49
    {
50
        return $this->get('id');
51
    }
52
53
    public function getIndex(): ?string
54
    {
55
        return $this->get('index');
56
    }
57
58
    public function getArea(): ?string
59
    {
60
        return $this->get('area');
61
    }
62
63
    public function getPlace(): ?string
64
    {
65
        return $this->get('place');
66
    }
67
68
    public function getRegion(): ?string
69
    {
70
        return $this->get('region');
71
    }
72
73
    public function getLocation(): ?string
74
    {
75
        return $this->get('location');
76
    }
77
78
    public function getStreet(): ?string
79
    {
80
        return $this->get('street');
81
    }
82
83
    public function getHouse(): ?string
84
    {
85
        return $this->get('house');
86
    }
87
88
    public function getRoom(): ?string
89
    {
90
        return $this->get('room');
91
    }
92
93
    public function getSlash(): ?string
94
    {
95
        return $this->get('slash');
96
    }
97
98
    public function getBuilding(): ?string
99
    {
100
        return $this->get('building');
101
    }
102
103
    public function getCorpus(): ?string
104
    {
105
        return $this->get('corpus');
106
    }
107
108
    public function getLetter(): ?string
109
    {
110
        return $this->get('letter');
111
    }
112
113
    public function getHotel(): ?string
114
    {
115
        return $this->get('hotel');
116
    }
117
118
    public function getNumAddressType(): ?string
119
    {
120
        return $this->get('num-address-type');
121
    }
122
123
    public function getOriginalAddress(): string
124
    {
125
        return $this->get('original-address');
126
    }
127
128
    public function getAddressType(): string
129
    {
130
        return $this->get('address-type');
131
    }
132
133
    public function getQualityCode(): string
134
    {
135
        return $this->get('quality-code');
136
    }
137
138
    public function getValidationCode(): string
139
    {
140
        return $this->get('validation-code');
141
    }
142
143
    public function isUseful(): bool
144
    {
145
        $quality = \in_array($this->getQualityCode(), [
146
            self::QUALITY_GOOD, self::QUALITY_POSTAL_BOX, self::QUALITY_ON_DEMAND, self::QUALITY_UNDEF_05,
147
        ]);
148
149
        $validity = \in_array($this->getValidationCode(), [
150
            self::VALIDATION_VALIDATED, self::VALIDATION_OVERRIDDEN, self::VALIDATION_CONFIRMED_MANUALLY,
151
        ]);
152
153
        return $quality && $validity;
154
    }
155
}
156