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

NormalizedPhone::isUseful()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 6
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 4
c 0
b 0
f 0
dl 0
loc 6
rs 10
cc 2
nc 2
nop 0
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Appwilio\RussianPostSDK\Dispatching\Endpoints\Services\Entities;
6
7
use Appwilio\RussianPostSDK\Dispatching\DataAware;
8
use Appwilio\RussianPostSDK\Dispatching\Contracts\Arrayable;
9
10
final class NormalizedPhone implements Arrayable
11
{
12
    use DataAware;
13
14
    /**
15
     * Коды качества нормализации телефона.
16
     *
17
     * @see https://otpravka.pochta.ru/specification#/enums-clean-fio-phone-quality
18
     */
19
    public const QUALITY_UNDEF = 'UNDEF';
20
    public const QUALITY_EMPTY = 'EMPTY';
21
    public const QUALITY_GARBAGE = 'GARBAGE';
22
    public const QUALITY_INCORRECT_DATA = 'INCORRECT_DATA';
23
    public const QUALITY_FOREIGN = 'FOREIGN';
24
    public const QUALITY_CODE_AMBI = 'CODE_AMBI';
25
    public const QUALITY_GOOD = 'GOOD';
26
    public const QUALITY_GOOD_CITY = 'GOOD_CITY';
27
    public const QUALITY_GOOD_EXTRA_PHONE = 'GOOD_EXTRA_PHONE';
28
    public const QUALITY_GOOD_REPLACED_CODE = 'GOOD_REPLACED_CODE';
29
    public const QUALITY_GOOD_REPLACED_NUMBER = 'GOOD_REPLACED_NUMBER';
30
    public const QUALITY_GOOD_REPLACED_CODE_NUMBER = 'GOOD_REPLACED_CODE_NUMBER';
31
    public const QUALITY_GOOD_CITY_CONFLICT = 'GOOD_CITY_CONFLICT';
32
    public const QUALITY_GOOD_REGION_CONFLICT = 'GOOD_REGION_CONFLICT';
33
    public const QUALITY_CONFIRMED_MANUALLY = 'CONFIRMED_MANUALLY';
34
35
    public function getId(): string
36
    {
37
        return $this->get('id');
38
    }
39
40
    public function getCountryCode(): string
41
    {
42
        return $this->get('phone-country-code');
43
    }
44
45
    public function getCityCode(): string
46
    {
47
        return $this->get('phone-city-code');
48
    }
49
50
    public function getNumber(): string
51
    {
52
        return $this->get('phone-number');
53
    }
54
55
    public function getExtension(): string
56
    {
57
        return $this->get('phone-extension');
58
    }
59
60
    public function getOriginalPhone(): string
61
    {
62
        return $this->get('original-phone');
63
    }
64
65
    public function getQualityCode(): string
66
    {
67
        return $this->get('quality-code');
68
    }
69
70
    public function isUseful(): bool
71
    {
72
        return
73
            $this->getQualityCode() === self::QUALITY_CONFIRMED_MANUALLY
74
            ||
75
            \strpos($this->getQualityCode(), self::QUALITY_GOOD) === 0;
76
    }
77
}
78