@@ -59,8 +59,12 @@ discard block |
||
59 | 59 | $address->setStreet($street); |
60 | 60 | $address->setPeople($people); |
61 | 61 | } |
62 | - if ($latitude > 0) $address->setLatitude($latitude); |
|
63 | - if ($longitude > 0) $address->setLongitude($longitude); |
|
62 | + if ($latitude > 0) { |
|
63 | + $address->setLatitude($latitude); |
|
64 | + } |
|
65 | + if ($longitude > 0) { |
|
66 | + $address->setLongitude($longitude); |
|
67 | + } |
|
64 | 68 | |
65 | 69 | |
66 | 70 | $this->manager->persist($address); |
@@ -125,16 +129,19 @@ discard block |
||
125 | 129 | } |
126 | 130 | public function discoveryCity(State $state, ?string $cityName = null, ?string $cod_ibge = null): City |
127 | 131 | { |
128 | - if (!$cityName && !$cod_ibge) |
|
129 | - throw new Exception("Need a param to search city", 404); |
|
132 | + if (!$cityName && !$cod_ibge) { |
|
133 | + throw new Exception("Need a param to search city", 404); |
|
134 | + } |
|
130 | 135 | |
131 | 136 | $search = [ |
132 | 137 | 'state' => $state |
133 | 138 | ]; |
134 | - if ($state) |
|
135 | - $search['city'] = $cityName; |
|
136 | - if ($cod_ibge) |
|
137 | - $search['cod_ibge'] = $cod_ibge; |
|
139 | + if ($state) { |
|
140 | + $search['city'] = $cityName; |
|
141 | + } |
|
142 | + if ($cod_ibge) { |
|
143 | + $search['cod_ibge'] = $cod_ibge; |
|
144 | + } |
|
138 | 145 | |
139 | 146 | $city = $this->manager->getRepository(City::class)->findOneBy($search); |
140 | 147 | |
@@ -150,18 +157,22 @@ discard block |
||
150 | 157 | } |
151 | 158 | public function discoveryState(Country $country, ?string $uf = null, ?string $stateName = null, ?string $cod_ibge = null): State |
152 | 159 | { |
153 | - if (!$uf && !$stateName && !$cod_ibge) |
|
154 | - throw new Exception("Need a param to search state", 404); |
|
160 | + if (!$uf && !$stateName && !$cod_ibge) { |
|
161 | + throw new Exception("Need a param to search state", 404); |
|
162 | + } |
|
155 | 163 | |
156 | 164 | $search = [ |
157 | 165 | 'country' => $country |
158 | 166 | ]; |
159 | - if ($stateName) |
|
160 | - $search['state'] = $stateName; |
|
161 | - if ($cod_ibge) |
|
162 | - $search['cod_ibge'] = $cod_ibge; |
|
163 | - if ($uf) |
|
164 | - $search['uf'] = $uf; |
|
167 | + if ($stateName) { |
|
168 | + $search['state'] = $stateName; |
|
169 | + } |
|
170 | + if ($cod_ibge) { |
|
171 | + $search['cod_ibge'] = $cod_ibge; |
|
172 | + } |
|
173 | + if ($uf) { |
|
174 | + $search['uf'] = $uf; |
|
175 | + } |
|
165 | 176 | |
166 | 177 | $state = $this->manager->getRepository(State::class)->findOneBy($search); |
167 | 178 |