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 NormalizedPhone implements Arrayable |
20
|
|
|
{ |
21
|
|
|
use DataAware; |
22
|
|
|
|
23
|
|
|
/** |
24
|
|
|
* Коды качества нормализации телефона. |
25
|
|
|
* |
26
|
|
|
* @see https://otpravka.pochta.ru/specification#/enums-clean-fio-phone-quality |
27
|
|
|
*/ |
28
|
|
|
public const QUALITY_UNDEF = 'UNDEF'; |
29
|
|
|
public const QUALITY_EMPTY = 'EMPTY'; |
30
|
|
|
public const QUALITY_GARBAGE = 'GARBAGE'; |
31
|
|
|
public const QUALITY_INCORRECT_DATA = 'INCORRECT_DATA'; |
32
|
|
|
public const QUALITY_FOREIGN = 'FOREIGN'; |
33
|
|
|
public const QUALITY_CODE_AMBI = 'CODE_AMBI'; |
34
|
|
|
public const QUALITY_GOOD = 'GOOD'; |
35
|
|
|
public const QUALITY_GOOD_CITY = 'GOOD_CITY'; |
36
|
|
|
public const QUALITY_GOOD_EXTRA_PHONE = 'GOOD_EXTRA_PHONE'; |
37
|
|
|
public const QUALITY_GOOD_REPLACED_CODE = 'GOOD_REPLACED_CODE'; |
38
|
|
|
public const QUALITY_GOOD_REPLACED_NUMBER = 'GOOD_REPLACED_NUMBER'; |
39
|
|
|
public const QUALITY_GOOD_REPLACED_CODE_NUMBER = 'GOOD_REPLACED_CODE_NUMBER'; |
40
|
|
|
public const QUALITY_GOOD_CITY_CONFLICT = 'GOOD_CITY_CONFLICT'; |
41
|
|
|
public const QUALITY_GOOD_REGION_CONFLICT = 'GOOD_REGION_CONFLICT'; |
42
|
|
|
public const QUALITY_CONFIRMED_MANUALLY = 'CONFIRMED_MANUALLY'; |
43
|
|
|
|
44
|
1 |
|
public function getId(): string |
45
|
|
|
{ |
46
|
1 |
|
return $this->get('id'); |
47
|
|
|
} |
48
|
|
|
|
49
|
1 |
|
public function getCountryCode(): string |
50
|
|
|
{ |
51
|
1 |
|
return $this->get('phone-country-code'); |
52
|
|
|
} |
53
|
|
|
|
54
|
1 |
|
public function getCityCode(): string |
55
|
|
|
{ |
56
|
1 |
|
return $this->get('phone-city-code'); |
57
|
|
|
} |
58
|
|
|
|
59
|
1 |
|
public function getNumber(): string |
60
|
|
|
{ |
61
|
1 |
|
return $this->get('phone-number'); |
62
|
|
|
} |
63
|
|
|
|
64
|
1 |
|
public function getExtension(): string |
65
|
|
|
{ |
66
|
1 |
|
return $this->get('phone-extension'); |
67
|
|
|
} |
68
|
|
|
|
69
|
1 |
|
public function getOriginalPhone(): string |
70
|
|
|
{ |
71
|
1 |
|
return $this->get('original-phone'); |
72
|
|
|
} |
73
|
|
|
|
74
|
1 |
|
public function getQualityCode(): string |
75
|
|
|
{ |
76
|
1 |
|
return $this->get('quality-code'); |
77
|
|
|
} |
78
|
|
|
|
79
|
|
|
public function isUseful(): bool |
80
|
|
|
{ |
81
|
|
|
return |
82
|
|
|
$this->getQualityCode() === self::QUALITY_CONFIRMED_MANUALLY |
83
|
|
|
|| |
84
|
|
|
\strpos($this->getQualityCode(), self::QUALITY_GOOD) === 0; |
85
|
|
|
} |
86
|
|
|
} |
87
|
|
|
|