@@ -15,17 +15,17 @@ discard block |
||
15 | 15 | private $url; |
16 | 16 | |
17 | 17 | /** @var RegionBranch[]|null */ |
18 | - private $all=null; |
|
18 | + private $all = null; |
|
19 | 19 | |
20 | 20 | /** |
21 | 21 | * RegionBranchStoreUrlJson constructor. |
22 | 22 | * @param $url |
23 | 23 | */ |
24 | - public function __construct(?UrlValue $url=null) |
|
24 | + public function __construct(?UrlValue $url = null) |
|
25 | 25 | { |
26 | 26 | $this->url = $url; |
27 | - if(empty($this->url)){ |
|
28 | - $this->url=new UrlValue('https://www.rshb.ru/promo/smb/rko-partner/js/region.json'); |
|
27 | + if (empty($this->url)) { |
|
28 | + $this->url = new UrlValue('https://www.rshb.ru/promo/smb/rko-partner/js/region.json'); |
|
29 | 29 | } |
30 | 30 | } |
31 | 31 | |
@@ -36,27 +36,27 @@ discard block |
||
36 | 36 | */ |
37 | 37 | public function findAll(): array |
38 | 38 | { |
39 | - if($this->all){ |
|
39 | + if ($this->all) { |
|
40 | 40 | return $this->all; |
41 | 41 | } |
42 | 42 | |
43 | 43 | |
44 | - $resource=file_get_contents($this->url->__toString()); |
|
45 | - if(empty($resource)){ |
|
44 | + $resource = file_get_contents($this->url->__toString()); |
|
45 | + if (empty($resource)) { |
|
46 | 46 | return []; |
47 | 47 | } |
48 | 48 | |
49 | - try{ |
|
50 | - $resource=json_decode($resource,true); |
|
51 | - if(!$resource){ |
|
49 | + try { |
|
50 | + $resource = json_decode($resource, true); |
|
51 | + if (!$resource) { |
|
52 | 52 | return []; |
53 | 53 | } |
54 | - }catch (\Exception $e){ |
|
54 | + }catch (\Exception $e) { |
|
55 | 55 | return []; |
56 | 56 | } |
57 | - foreach ($resource as $item){ |
|
58 | - $this->all[]=new RegionBranch( |
|
59 | - (int)$item['id'], |
|
57 | + foreach ($resource as $item) { |
|
58 | + $this->all[] = new RegionBranch( |
|
59 | + (int) $item['id'], |
|
60 | 60 | $item['origName'], |
61 | 61 | $item['newName'] |
62 | 62 | ); |
@@ -69,8 +69,8 @@ discard block |
||
69 | 69 | */ |
70 | 70 | public function findByRegion(string $region): ?RegionBranch |
71 | 71 | { |
72 | - foreach ($this->findAll() as $regionBranch){ |
|
73 | - if($regionBranch->getRegionName()==$region){ |
|
72 | + foreach ($this->findAll() as $regionBranch) { |
|
73 | + if ($regionBranch->getRegionName() == $region) { |
|
74 | 74 | return $regionBranch; |
75 | 75 | } |
76 | 76 | } |
@@ -80,8 +80,8 @@ discard block |
||
80 | 80 | |
81 | 81 | public function findById(int $id): ?RegionBranch |
82 | 82 | { |
83 | - foreach ($this->findAll() as $regionBranch){ |
|
84 | - if($regionBranch->getId()==$id){ |
|
83 | + foreach ($this->findAll() as $regionBranch) { |
|
84 | + if ($regionBranch->getId() == $id) { |
|
85 | 85 | return $regionBranch; |
86 | 86 | } |
87 | 87 | } |