Bitrix-D7 23.9
 
Загрузка...
Поиск...
Не найдено
usconverter.php
1<?php
2
4
13final class UsConverter extends BaseConverter
14{
16 private const STATE_ADMIN_LEVEL = 4;
17
19 private const COUNTY_ADMIN_LEVEL = 6;
20
26 private const NY_STATE_RELATION_ID = 61320;
27
29 private const NY_CITY_ADMIN_LEVEL = 5;
30
34 protected function getAdminLevel1(): ?array
35 {
36 foreach ($this->addressComponents as $addressComponent)
37 {
38 if ($this->isAdministrativeBoundary($addressComponent)
39 && $addressComponent['admin_level'] === static::STATE_ADMIN_LEVEL
40 )
41 {
42 return $addressComponent;
43 }
44 }
45
46 return null;
47 }
48
52 protected function getAdminLevel2(): ?array
53 {
54 foreach ($this->addressComponents as $addressComponent)
55 {
56 if ($this->isAdministrativeBoundary($addressComponent)
57 && $addressComponent['admin_level'] === static::COUNTY_ADMIN_LEVEL
58 )
59 {
60 return $addressComponent;
61 }
62 }
63
64 return null;
65 }
66
70 protected function getLocalityConcrete(): ?array
71 {
72 if ($this->isCityState())
73 {
74 foreach ($this->addressComponents as $addressComponent)
75 {
76 if ($addressComponent['class'] === 'boundary'
77 && $addressComponent['type'] === 'administrative'
78 && $addressComponent['admin_level'] === static::NY_CITY_ADMIN_LEVEL
79 )
80 {
81 return $addressComponent;
82 }
83 }
84 }
85
86 return parent::getLocalityConcrete();
87 }
88
92 protected function getCityStateRelationIds(): array
93 {
94 return [
95 static::NY_STATE_RELATION_ID,
96 ];
97 }
98}