Completed
Branch master (a0b8e2)
by Konstantin
02:08
created
app/GeoFixerFacade.php 3 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -242,7 +242,7 @@
 block discarded – undo
242 242
      * @param $street_id
243 243
      * @param bool $building
244 244
      *
245
-     * @return string|false
245
+     * @return boolean
246 246
      */
247 247
     public function findFiasHouse($house, $street_id, $building = false)
248 248
     {
Please login to merge, or discard this patch.
Unused Use Statements   -1 removed lines patch added patch discarded remove patch
@@ -3,7 +3,6 @@
 block discarded – undo
3 3
 
4 4
 use GeoFixer\models\GeoFixer;
5 5
 use GeoFixer\models\DatabaseConnection;
6
-
7 6
 use Katzgrau\KLogger;
8 7
 use Exception;
9 8
 
Please login to merge, or discard this patch.
Spacing   +19 added lines, -19 removed lines patch added patch discarded remove patch
@@ -68,7 +68,7 @@  discard block
 block discarded – undo
68 68
 
69 69
         if ($result == false) {
70 70
             $this->logger->warning('Не найдено похожее слово: ' . $word);
71
-            $this->logger->warning('Строгий режим: ' . (int)$strict_search);
71
+            $this->logger->warning('Строгий режим: ' . (int) $strict_search);
72 72
             $this->logger->warning('Массива для поиска: ' . implode($search_array, ', ') . PHP_EOL);
73 73
         }
74 74
 
@@ -90,12 +90,12 @@  discard block
 block discarded – undo
90 90
         $this->geo->isStrict($strict_search);
91 91
         $this->geo->isFirstLetters($first_letters);
92 92
 
93
-        $result =  $this->geo->findFiasRegion($region);
93
+        $result = $this->geo->findFiasRegion($region);
94 94
 
95 95
         if ($result == false) {
96 96
             $this->logger->warning('Не найден регион ' . $region . ' в базе ФИАС');
97
-            $this->logger->warning('Строгий режим: ' . (int)$strict_search);
98
-            $this->logger->warning('Режим "совпадают первые буквы": ' . (int)$first_letters . PHP_EOL);
97
+            $this->logger->warning('Строгий режим: ' . (int) $strict_search);
98
+            $this->logger->warning('Режим "совпадают первые буквы": ' . (int) $first_letters . PHP_EOL);
99 99
         }
100 100
 
101 101
         return $result;
@@ -139,12 +139,12 @@  discard block
 block discarded – undo
139 139
         $this->geo->isFirstLetters($first_letters);
140 140
         $this->geo->isFullSettlements($full_settlements);
141 141
 
142
-        $result =  $this->geo->findFiasSettlements($city, $region_code);
142
+        $result = $this->geo->findFiasSettlements($city, $region_code);
143 143
 
144 144
         if ($result == false) {
145 145
             $this->logger->warning('Не найден город ' . $city . ' в регионе с кодом ' . $region_code . ' базы ФИАС');
146
-            $this->logger->warning('Строгий режим: ' . (int)$strict_search);
147
-            $this->logger->warning('Режим "совпадают первые буквы": ' . (int)$first_letters . PHP_EOL);
146
+            $this->logger->warning('Строгий режим: ' . (int) $strict_search);
147
+            $this->logger->warning('Режим "совпадают первые буквы": ' . (int) $first_letters . PHP_EOL);
148 148
         }
149 149
 
150 150
         return $result;
@@ -169,12 +169,12 @@  discard block
 block discarded – undo
169 169
 
170 170
         $region_code = substr($region_code, 0, 2);
171 171
 
172
-        $result =  $this->geo->findKladrSettlements($city, $region_code);
172
+        $result = $this->geo->findKladrSettlements($city, $region_code);
173 173
 
174 174
         if ($result == false) {
175 175
             $this->logger->warning('Не найден город ' . $city . ' в регионе с кодом ' . $region_code . ' базы ФИАС');
176
-            $this->logger->warning('Строгий режим: ' . (int)$strict_search);
177
-            $this->logger->warning('Режим "совпадают первые буквы": ' . (int)$first_letters . PHP_EOL);
176
+            $this->logger->warning('Строгий режим: ' . (int) $strict_search);
177
+            $this->logger->warning('Режим "совпадают первые буквы": ' . (int) $first_letters . PHP_EOL);
178 178
         }
179 179
 
180 180
         return $result;
@@ -196,12 +196,12 @@  discard block
 block discarded – undo
196 196
         $this->geo->isStrict($strict_search);
197 197
         $this->geo->isFirstLetters($first_letters);
198 198
 
199
-        $result =  $this->geo->findFiasStreets($street, $city_id);
199
+        $result = $this->geo->findFiasStreets($street, $city_id);
200 200
 
201 201
         if ($result == false) {
202 202
             $this->logger->warning('Не найдена улица ' . $street . ' в городе с id ' . $city_id . ' базы ФИАС');
203
-            $this->logger->warning('Строгий режим: ' . (int)$strict_search);
204
-            $this->logger->warning('Режим "совпадают первые буквы": ' . (int)$first_letters . PHP_EOL);
203
+            $this->logger->warning('Строгий режим: ' . (int) $strict_search);
204
+            $this->logger->warning('Режим "совпадают первые буквы": ' . (int) $first_letters . PHP_EOL);
205 205
         }
206 206
 
207 207
         return $result;
@@ -223,12 +223,12 @@  discard block
 block discarded – undo
223 223
         $this->geo->isStrict($strict_search);
224 224
         $this->geo->isFirstLetters($first_letters);
225 225
 
226
-        $result =  $this->geo->findKladrStreets($street, $city_code);
226
+        $result = $this->geo->findKladrStreets($street, $city_code);
227 227
 
228 228
         if ($result == false) {
229 229
             $this->logger->warning('Не найдена улица ' . $street . ' в городе с кодом ' . $city_code . ' базы КЛАДР');
230
-            $this->logger->warning('Строгий режим: ' . (int)$strict_search);
231
-            $this->logger->warning('Режим "совпадают первые буквы": ' . (int)$first_letters . PHP_EOL);
230
+            $this->logger->warning('Строгий режим: ' . (int) $strict_search);
231
+            $this->logger->warning('Режим "совпадают первые буквы": ' . (int) $first_letters . PHP_EOL);
232 232
         }
233 233
 
234 234
         return $result;
@@ -246,13 +246,13 @@  discard block
 block discarded – undo
246 246
      */
247 247
     public function findFiasHouse($house, $street_id, $building = false)
248 248
     {
249
-        $result =  $this->geo->findFiasHouses($house, $street_id, $building);
249
+        $result = $this->geo->findFiasHouses($house, $street_id, $building);
250 250
 
251 251
         if ($result == false) {
252 252
             if ($building) {
253
-                $this->logger->warning('Не найден дом ' .  $house . ', корпус ' . $building . ' на улице с id ' . $street_id . ' базы ФИАС' . PHP_EOL);
253
+                $this->logger->warning('Не найден дом ' . $house . ', корпус ' . $building . ' на улице с id ' . $street_id . ' базы ФИАС' . PHP_EOL);
254 254
             } else {
255
-                $this->logger->warning('Не найден дом ' .  $house . ' на улице с id ' . $street_id . ' базы ФИАС: ' . $house . PHP_EOL);
255
+                $this->logger->warning('Не найден дом ' . $house . ' на улице с id ' . $street_id . ' базы ФИАС: ' . $house . PHP_EOL);
256 256
             }
257 257
         }
258 258
 
Please login to merge, or discard this patch.
app/models/GeoFixer.php 2 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -110,7 +110,7 @@
 block discarded – undo
110 110
 
111 111
     /**
112 112
      * @param $city
113
-     * @param $region_code
113
+     * @param string $region_code
114 114
      *
115 115
      * @return bool|mixed
116 116
      */
Please login to merge, or discard this patch.
Spacing   +29 added lines, -29 removed lines patch added patch discarded remove patch
@@ -65,17 +65,17 @@  discard block
 block discarded – undo
65 65
 
66 66
         $regions = $regions->findAll();
67 67
 
68
-        $titles = [];
69
-        $regions_with_codes = [];
68
+        $titles = [ ];
69
+        $regions_with_codes = [ ];
70 70
 
71 71
         foreach ($regions as $v) {
72
-            $regions_with_codes[$v['title']] = $v['code'];
73
-            $titles[] = $v['title'];
72
+            $regions_with_codes[ $v[ 'title' ] ] = $v[ 'code' ];
73
+            $titles[ ] = $v[ 'title' ];
74 74
         }
75 75
 
76 76
         $result = $this->findSimilarWord($region, $titles);
77 77
 
78
-        return $result ? $regions_with_codes[$result] : false;
78
+        return $result ? $regions_with_codes[ $result ] : false;
79 79
     }
80 80
 
81 81
     /**
@@ -95,17 +95,17 @@  discard block
 block discarded – undo
95 95
 
96 96
         $settlements = $settlements->findAll();
97 97
 
98
-        $titles = [];
99
-        $settlements_with_id = [];
98
+        $titles = [ ];
99
+        $settlements_with_id = [ ];
100 100
 
101 101
         foreach ($settlements as $v) {
102
-            $settlements_with_id[$v['title']] = $v['address_id'];
103
-            $titles[] = $v['title'];
102
+            $settlements_with_id[ $v[ 'title' ] ] = $v[ 'address_id' ];
103
+            $titles[ ] = $v[ 'title' ];
104 104
         }
105 105
 
106 106
         $result = $this->findSimilarWord($city, $titles);
107 107
 
108
-        return $result ? $settlements_with_id[$result] : false;
108
+        return $result ? $settlements_with_id[ $result ] : false;
109 109
     }
110 110
 
111 111
     /**
@@ -125,12 +125,12 @@  discard block
 block discarded – undo
125 125
 
126 126
         $settlements = $settlements->findAll();
127 127
 
128
-        $titles = [];
129
-        $settlements_with_id = [];
128
+        $titles = [ ];
129
+        $settlements_with_id = [ ];
130 130
 
131 131
         foreach ($settlements as $v) {
132
-            $settlements_with_id[$v['title']] = $v['code'];
133
-            $titles[] = $v['title'];
132
+            $settlements_with_id[ $v[ 'title' ] ] = $v[ 'code' ];
133
+            $titles[ ] = $v[ 'title' ];
134 134
         }
135 135
 
136 136
         $result = $this->findSimilarWord($city, $titles);
@@ -138,11 +138,11 @@  discard block
 block discarded – undo
138 138
         if (!$result) {
139 139
             return false;
140 140
         }
141
-        if (is_null($settlements_with_id[$result])) {
141
+        if (is_null($settlements_with_id[ $result ])) {
142 142
             return false;
143 143
         }
144 144
 
145
-        return $settlements_with_id[$result];
145
+        return $settlements_with_id[ $result ];
146 146
     }
147 147
 
148 148
     /**
@@ -162,17 +162,17 @@  discard block
 block discarded – undo
162 162
 
163 163
         $streets = $streets->findAll();
164 164
 
165
-        $titles = [];
166
-        $streets_with_id = [];
165
+        $titles = [ ];
166
+        $streets_with_id = [ ];
167 167
 
168 168
         foreach ($streets as $v) {
169
-            $streets_with_id[$v['title']] = $v['address_id'];
170
-            $titles[] = $v['title'];
169
+            $streets_with_id[ $v[ 'title' ] ] = $v[ 'address_id' ];
170
+            $titles[ ] = $v[ 'title' ];
171 171
         }
172 172
 
173 173
         $result = $this->findSimilarWord($street, $titles);
174 174
 
175
-        return $result ? $streets_with_id[$result] : false;
175
+        return $result ? $streets_with_id[ $result ] : false;
176 176
     }
177 177
 
178 178
     /**
@@ -187,7 +187,7 @@  discard block
 block discarded – undo
187 187
         $city = new SettlementsDatabaseQuery();
188 188
         $city_id = $city->getSettlements()->addressLevel(true)->kladrCode($city_code)->findOne();
189 189
         if ($city_id) {
190
-            $city_id = $city_id['address_id'];
190
+            $city_id = $city_id[ 'address_id' ];
191 191
         } else {
192 192
             return false;
193 193
         }
@@ -199,12 +199,12 @@  discard block
 block discarded – undo
199 199
 
200 200
         $streets = $streets->findAll();
201 201
 
202
-        $titles = [];
203
-        $streets_with_id = [];
202
+        $titles = [ ];
203
+        $streets_with_id = [ ];
204 204
 
205 205
         foreach ($streets as $v) {
206
-            $streets_with_id[$v['title']] = $v['code'];
207
-            $titles[] = $v['title'];
206
+            $streets_with_id[ $v[ 'title' ] ] = $v[ 'code' ];
207
+            $titles[ ] = $v[ 'title' ];
208 208
         }
209 209
 
210 210
         $result = $this->findSimilarWord($street, $titles);
@@ -212,11 +212,11 @@  discard block
 block discarded – undo
212 212
         if (!$result) {
213 213
             return false;
214 214
         }
215
-        if (is_null($streets_with_id[$result])) {
215
+        if (is_null($streets_with_id[ $result ])) {
216 216
             return false;
217 217
         }
218 218
 
219
-        return $streets_with_id[$result];
219
+        return $streets_with_id[ $result ];
220 220
     }
221 221
 
222 222
     /**
@@ -236,7 +236,7 @@  discard block
 block discarded – undo
236 236
 
237 237
         $house_id = $house_id->findOne();
238 238
 
239
-        return $house_id ? $house_id['house_id'] : false;
239
+        return $house_id ? $house_id[ 'house_id' ] : false;
240 240
     }
241 241
 
242 242
     /**
Please login to merge, or discard this patch.
app/models/queries/AbstractDatabaseQuery.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -43,7 +43,7 @@  discard block
 block discarded – undo
43 43
      */
44 44
     public function firstLetters($letters)
45 45
     {
46
-        $this->db = $this->db->andWhere(['title LIKE' => $letters . '%']);
46
+        $this->db = $this->db->andWhere([ 'title LIKE' => $letters . '%' ]);
47 47
 
48 48
         return $this;
49 49
     }
@@ -57,7 +57,7 @@  discard block
 block discarded – undo
57 57
      */
58 58
     public function regionCode($code)
59 59
     {
60
-        $this->db = $this->db->andWhere(['region_code' => $code]);
60
+        $this->db = $this->db->andWhere([ 'region_code' => $code ]);
61 61
 
62 62
         return $this;
63 63
     }
@@ -71,7 +71,7 @@  discard block
 block discarded – undo
71 71
      */
72 72
     public function kladrCode($code)
73 73
     {
74
-        $this->db = $this->db->andWhere(['code' => $code]);
74
+        $this->db = $this->db->andWhere([ 'code' => $code ]);
75 75
 
76 76
         return $this;
77 77
     }
@@ -85,7 +85,7 @@  discard block
 block discarded – undo
85 85
      */
86 86
     public function parentId($id)
87 87
     {
88
-        $this->db = $this->db->andWhere(['parent_id' => $id]);
88
+        $this->db = $this->db->andWhere([ 'parent_id' => $id ]);
89 89
 
90 90
         return $this;
91 91
     }
Please login to merge, or discard this patch.
app/models/queries/StreetsDatabaseQuery.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -24,7 +24,7 @@  discard block
 block discarded – undo
24 24
      */
25 25
     public function getStreets()
26 26
     {
27
-        $this->db = $this->db->select(['address_id', 'title', 'code'])->from('fias_address_object');
27
+        $this->db = $this->db->select([ 'address_id', 'title', 'code' ])->from('fias_address_object');
28 28
 
29 29
         return $this;
30 30
     }
@@ -36,7 +36,7 @@  discard block
 block discarded – undo
36 36
      */
37 37
     public function addressLevel()
38 38
     {
39
-        $this->db = $this->db->andWhere(['address_level' => self::STREET]);
39
+        $this->db = $this->db->andWhere([ 'address_level' => self::STREET ]);
40 40
 
41 41
         return $this;
42 42
     }
Please login to merge, or discard this patch.
app/models/queries/SettlementsDatabaseQuery.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -24,7 +24,7 @@  discard block
 block discarded – undo
24 24
      */
25 25
     public function getSettlements()
26 26
     {
27
-        $this->db = $this->db->select(['address_id', 'title', 'code'])->from('fias_address_object');
27
+        $this->db = $this->db->select([ 'address_id', 'title', 'code' ])->from('fias_address_object');
28 28
 
29 29
         return $this;
30 30
     }
@@ -39,9 +39,9 @@  discard block
 block discarded – undo
39 39
     public function addressLevel($full_settlements = false)
40 40
     {
41 41
         if ($full_settlements == false) {
42
-            $this->db = $this->db->andWhere(['address_level' => self::CITY]);
42
+            $this->db = $this->db->andWhere([ 'address_level' => self::CITY ]);
43 43
         } else {
44
-            $this->db = $this->db->andWhere(['OR' => [['address_level' => self::CITY], ['address_level' => self::SETTLEMENT]]]);
44
+            $this->db = $this->db->andWhere([ 'OR' => [ [ 'address_level' => self::CITY ], [ 'address_level' => self::SETTLEMENT ] ] ]);
45 45
         }
46 46
 
47 47
         return $this;
Please login to merge, or discard this patch.