Conditions | 3 |
Paths | 4 |
Total Lines | 22 |
Lines | 0 |
Ratio | 0 % |
Changes | 0 |
1 | <?php |
||
103 | public static function fromApi(array $data): self |
||
104 | { |
||
105 | $geo = null; |
||
106 | $country = null; |
||
107 | |||
108 | if ($data['coords']) { |
||
109 | $geo = Geo::fromApi($data['coords']); |
||
110 | } |
||
111 | |||
112 | if ($data['country']) { |
||
113 | $country = Country::fromApi($data['country']); |
||
114 | } |
||
115 | |||
116 | return new self( |
||
117 | (int) $data['id'], |
||
118 | $data['name'], |
||
119 | $data['state'] ?? null, |
||
120 | $data['stateCode'] ?? null, |
||
121 | $country, |
||
122 | $geo |
||
123 | ); |
||
124 | } |
||
125 | } |
||
126 |