Conditions | 6 |
Paths | 6 |
Total Lines | 28 |
Code Lines | 17 |
Lines | 0 |
Ratio | 0 % |
Changes | 2 | ||
Bugs | 1 | Features | 0 |
1 | <?php |
||
37 | public function findAll(): array |
||
38 | { |
||
39 | if($this->all){ |
||
40 | return $this->all; |
||
41 | } |
||
42 | |||
43 | |||
44 | $resource=file_get_contents($this->url->__toString()); |
||
45 | if(empty($resource)){ |
||
46 | return []; |
||
47 | } |
||
48 | |||
49 | try{ |
||
50 | $resource=json_decode($resource,true); |
||
51 | if(!$resource){ |
||
52 | return []; |
||
53 | } |
||
54 | }catch (\Exception $e){ |
||
55 | return []; |
||
56 | } |
||
57 | foreach ($resource as $item){ |
||
58 | $this->all[]=new RegionBranch( |
||
59 | (int)$item['id'], |
||
60 | $item['origName'], |
||
61 | $item['newName'] |
||
62 | ); |
||
63 | } |
||
64 | return $this->all; |
||
|
|||
65 | } |
||
91 | } |