@@ -26,13 +26,13 @@ |
||
26 | 26 | public function __construct(Address $address, AddressDetails $address_details, Point $point, |
27 | 27 | $name, $description, $kind, $text) |
28 | 28 | { |
29 | - $this->address=$address; |
|
30 | - $this->address_details=$address_details; |
|
31 | - $this->point=$point; |
|
32 | - $this->name=$name; |
|
33 | - $this->description=$description; |
|
34 | - $this->kind=$kind; |
|
35 | - $this->text=$text; |
|
29 | + $this->address = $address; |
|
30 | + $this->address_details = $address_details; |
|
31 | + $this->point = $point; |
|
32 | + $this->name = $name; |
|
33 | + $this->description = $description; |
|
34 | + $this->kind = $kind; |
|
35 | + $this->text = $text; |
|
36 | 36 | } |
37 | 37 | |
38 | 38 | /** |
@@ -57,19 +57,19 @@ |
||
57 | 57 | */ |
58 | 58 | public static function fromState(array $state): self |
59 | 59 | { |
60 | - $addressLine=ArrayHelper::getValue($state,'Country.AddressLine'); |
|
61 | - $countryNameCode=ArrayHelper::getValue($state,'Country.CountryNameCode'); |
|
62 | - $countryName=ArrayHelper::getValue($state,'Country.CountryName'); |
|
63 | - $administrativeAreaName=ArrayHelper::getValue($state,'Country.AdministrativeArea.AdministrativeAreaName'); |
|
64 | - $subAdministrariveAreaName=ArrayHelper::getValue($state,'Country.AdministrativeArea.SubAdministrativeArea.SubAdministrativeAreaName'); |
|
65 | - $subAdm=ArrayHelper::getValue($state,'Country.AdministrativeArea.SubAdministrativeArea'); |
|
66 | - $locality=ArrayHelper::getValue($subAdm,'Locality.LocalityName'); |
|
67 | - $throughfareName=ArrayHelper::getValue($subAdm,'Locality.Thoroughfare.ThoroughfareName'); |
|
68 | - $premiseNumber=ArrayHelper::getValue($subAdm,'Locality.Thoroughfare.Premise.PremiseNumber'); |
|
69 | - $postalCodeNumber=ArrayHelper::getValue($subAdm,'Locality.Thoroughfare.Premise.PostalCode.PostalCodeNumber'); |
|
70 | - |
|
71 | - return new self($addressLine,$countryNameCode,$countryName,$administrativeAreaName, |
|
72 | - $subAdministrariveAreaName,$locality,$throughfareName,$premiseNumber,$postalCodeNumber); |
|
60 | + $addressLine = ArrayHelper::getValue($state, 'Country.AddressLine'); |
|
61 | + $countryNameCode = ArrayHelper::getValue($state, 'Country.CountryNameCode'); |
|
62 | + $countryName = ArrayHelper::getValue($state, 'Country.CountryName'); |
|
63 | + $administrativeAreaName = ArrayHelper::getValue($state, 'Country.AdministrativeArea.AdministrativeAreaName'); |
|
64 | + $subAdministrariveAreaName = ArrayHelper::getValue($state, 'Country.AdministrativeArea.SubAdministrativeArea.SubAdministrativeAreaName'); |
|
65 | + $subAdm = ArrayHelper::getValue($state, 'Country.AdministrativeArea.SubAdministrativeArea'); |
|
66 | + $locality = ArrayHelper::getValue($subAdm, 'Locality.LocalityName'); |
|
67 | + $throughfareName = ArrayHelper::getValue($subAdm, 'Locality.Thoroughfare.ThoroughfareName'); |
|
68 | + $premiseNumber = ArrayHelper::getValue($subAdm, 'Locality.Thoroughfare.Premise.PremiseNumber'); |
|
69 | + $postalCodeNumber = ArrayHelper::getValue($subAdm, 'Locality.Thoroughfare.Premise.PostalCode.PostalCodeNumber'); |
|
70 | + |
|
71 | + return new self($addressLine, $countryNameCode, $countryName, $administrativeAreaName, |
|
72 | + $subAdministrariveAreaName, $locality, $throughfareName, $premiseNumber, $postalCodeNumber); |
|
73 | 73 | } |
74 | 74 | |
75 | 75 | /** |
@@ -6,7 +6,7 @@ |
||
6 | 6 | |
7 | 7 | class FormatResponseException extends \Exception |
8 | 8 | { |
9 | - public function getName(){ |
|
9 | + public function getName() { |
|
10 | 10 | return 'Error Format Response'; |
11 | 11 | } |
12 | 12 |
@@ -7,7 +7,7 @@ |
||
7 | 7 | class ProxyConfException extends \Exception |
8 | 8 | { |
9 | 9 | |
10 | - public function getName(){ |
|
10 | + public function getName() { |
|
11 | 11 | return 'Proxy Config Exception'; |
12 | 12 | } |
13 | 13 |
@@ -6,6 +6,6 @@ |
||
6 | 6 | |
7 | 7 | interface Geocode |
8 | 8 | { |
9 | - public function get($query,$params=[]); |
|
9 | + public function get($query, $params = []); |
|
10 | 10 | |
11 | 11 | } |
12 | 12 | \ No newline at end of file |
@@ -29,17 +29,17 @@ |
||
29 | 29 | { |
30 | 30 | parent::init(); |
31 | 31 | |
32 | - if(\Yii::$container->has(\talismanfr\geocode\contracts\Geocode::class)){ |
|
33 | - $this->geocode=\Yii::$container->get(\talismanfr\geocode\contracts\Geocode::class); |
|
34 | - }else{ |
|
35 | - $geocode=new Geocode(); |
|
36 | - $geocode->apikey=$this->apikey; |
|
37 | - $geocode->useProxy=$this->useProxy; |
|
38 | - $geocode->proxyConf=$this->proxyConf; |
|
39 | - $this->geocode=$geocode; |
|
32 | + if (\Yii::$container->has(\talismanfr\geocode\contracts\Geocode::class)) { |
|
33 | + $this->geocode = \Yii::$container->get(\talismanfr\geocode\contracts\Geocode::class); |
|
34 | + }else { |
|
35 | + $geocode = new Geocode(); |
|
36 | + $geocode->apikey = $this->apikey; |
|
37 | + $geocode->useProxy = $this->useProxy; |
|
38 | + $geocode->proxyConf = $this->proxyConf; |
|
39 | + $this->geocode = $geocode; |
|
40 | 40 | } |
41 | 41 | |
42 | - $this->collection=new GeocodeCollection($this->geocode); |
|
42 | + $this->collection = new GeocodeCollection($this->geocode); |
|
43 | 43 | } |
44 | 44 | |
45 | 45 | public function get($query): array |
@@ -31,7 +31,7 @@ |
||
31 | 31 | |
32 | 32 | if(\Yii::$container->has(\talismanfr\geocode\contracts\Geocode::class)){ |
33 | 33 | $this->geocode=\Yii::$container->get(\talismanfr\geocode\contracts\Geocode::class); |
34 | - }else{ |
|
34 | + } else{ |
|
35 | 35 | $geocode=new Geocode(); |
36 | 36 | $geocode->apikey=$this->apikey; |
37 | 37 | $geocode->useProxy=$this->useProxy; |
@@ -40,12 +40,12 @@ discard block |
||
40 | 40 | * @return Geo |
41 | 41 | * @throws FormatResponseException |
42 | 42 | */ |
43 | - public function one($query,$params=[]) |
|
43 | + public function one($query, $params = []) |
|
44 | 44 | { |
45 | - $params['results']=1; |
|
46 | - $geos=$this->find($query,$params); |
|
45 | + $params['results'] = 1; |
|
46 | + $geos = $this->find($query, $params); |
|
47 | 47 | |
48 | - if(count($geos)>0){ |
|
48 | + if (count($geos)>0) { |
|
49 | 49 | return array_shift($geos); |
50 | 50 | } |
51 | 51 | |
@@ -71,9 +71,9 @@ discard block |
||
71 | 71 | $data = ArrayHelper::getValue($geo_result, 'response.GeoObjectCollection.featureMember'); |
72 | 72 | |
73 | 73 | if (!$data) { |
74 | - $meta=ArrayHelper::getValue($geo_result,'response.GeoObjectCollection.metaDataProperty.GeocoderResponseMetaData'); |
|
74 | + $meta = ArrayHelper::getValue($geo_result, 'response.GeoObjectCollection.metaDataProperty.GeocoderResponseMetaData'); |
|
75 | 75 | |
76 | - if(!$meta) { |
|
76 | + if (!$meta) { |
|
77 | 77 | throw new FormatResponseException('Error format response from query ' . $query); |
78 | 78 | } |
79 | 79 |
@@ -15,20 +15,20 @@ |
||
15 | 15 | /** @var \yii\caching\CacheInterface */ |
16 | 16 | private $cache; |
17 | 17 | |
18 | - public $duration=null; |
|
18 | + public $duration = null; |
|
19 | 19 | |
20 | - public $dependency=null; |
|
20 | + public $dependency = null; |
|
21 | 21 | |
22 | - public function __construct(Geocode $geocode,CacheInterface $cache) |
|
22 | + public function __construct(Geocode $geocode, CacheInterface $cache) |
|
23 | 23 | { |
24 | - $this->geocode=$geocode; |
|
25 | - $this->cache=$cache; |
|
24 | + $this->geocode = $geocode; |
|
25 | + $this->cache = $cache; |
|
26 | 26 | } |
27 | 27 | |
28 | 28 | public function get($query, $params = []) |
29 | 29 | { |
30 | - return $this->cache->getOrSet($query,function ()use($query){ |
|
30 | + return $this->cache->getOrSet($query, function()use($query){ |
|
31 | 31 | return $this->geocode->get($query); |
32 | - },$this->duration,$this->dependency); |
|
32 | + },$this->duration, $this->dependency); |
|
33 | 33 | } |
34 | 34 | } |
35 | 35 | \ No newline at end of file |
@@ -30,22 +30,22 @@ discard block |
||
30 | 30 | $this->components = $components; |
31 | 31 | } |
32 | 32 | |
33 | - public static function fromState(array $state){ |
|
34 | - $components=[]; |
|
33 | + public static function fromState(array $state) { |
|
34 | + $components = []; |
|
35 | 35 | |
36 | - foreach (ArrayHelper::getValue($state,'Components') as $componentState){ |
|
37 | - $kind=ArrayHelper::getValue($componentState,'kind'); |
|
38 | - $name=ArrayHelper::getValue($componentState,'name'); |
|
36 | + foreach (ArrayHelper::getValue($state, 'Components') as $componentState) { |
|
37 | + $kind = ArrayHelper::getValue($componentState, 'kind'); |
|
38 | + $name = ArrayHelper::getValue($componentState, 'name'); |
|
39 | 39 | |
40 | - $component=new AddressComponent($kind,$name); |
|
40 | + $component = new AddressComponent($kind, $name); |
|
41 | 41 | |
42 | - $components[$kind][]=$component; |
|
42 | + $components[$kind][] = $component; |
|
43 | 43 | } |
44 | 44 | |
45 | - $country_code=ArrayHelper::getValue($state,'country_code',''); |
|
46 | - $formatted=ArrayHelper::getValue($state,'formatted',''); |
|
45 | + $country_code = ArrayHelper::getValue($state, 'country_code', ''); |
|
46 | + $formatted = ArrayHelper::getValue($state, 'formatted', ''); |
|
47 | 47 | |
48 | - return new self($country_code,$formatted,$components); |
|
48 | + return new self($country_code, $formatted, $components); |
|
49 | 49 | } |
50 | 50 | |
51 | 51 | /** |
@@ -72,9 +72,9 @@ discard block |
||
72 | 72 | return $this->components; |
73 | 73 | } |
74 | 74 | |
75 | - public function getKindName($kind){ |
|
76 | - if(isset($this->components[$kind])){ |
|
77 | - $component=$this->components[$kind][count($this->components[$kind])-1]; |
|
75 | + public function getKindName($kind) { |
|
76 | + if (isset($this->components[$kind])) { |
|
77 | + $component = $this->components[$kind][count($this->components[$kind]) - 1]; |
|
78 | 78 | return $component->getName(); |
79 | 79 | } |
80 | 80 |