This project does not seem to handle request data directly as such no vulnerable execution paths were found.
include
, or for example
via PHP's auto-loading mechanism.
These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
1 | <?php |
||
2 | namespace GeoFixer; |
||
3 | |||
4 | use GeoFixer\models\GeoFixer; |
||
5 | use GeoFixer\models\DatabaseConnection; |
||
6 | |||
7 | use Katzgrau\KLogger; |
||
8 | use Exception; |
||
9 | |||
10 | /** |
||
11 | * Class GeoFixerFacade |
||
12 | * |
||
13 | * @package GeoFixer |
||
14 | */ |
||
15 | class GeoFixerFacade |
||
16 | { |
||
17 | /** |
||
18 | * @var KLogger\Logger |
||
19 | */ |
||
20 | private $logger; |
||
21 | |||
22 | /** |
||
23 | * @var GeoFixer |
||
24 | */ |
||
25 | private $geo; |
||
26 | |||
27 | /** |
||
28 | * Инициализируем (если передан параметр) БД и логирование |
||
29 | * |
||
30 | * GeoFixerFacade constructor. |
||
31 | * @param bool $fias |
||
32 | * @param bool $logger |
||
33 | * @param array $config |
||
34 | */ |
||
35 | 4 | public function __construct($fias = false, $logger = false, $config = null) |
|
36 | { |
||
37 | 4 | if ($logger !== false) { |
|
38 | 1 | $this->logger = new KLogger\Logger(dirname(dirname(__FILE__)) . '/logs'); |
|
39 | 1 | } else { |
|
40 | 3 | $this->logger = false; |
|
0 ignored issues
–
show
|
|||
41 | } |
||
42 | |||
43 | 4 | if ($fias === true) { |
|
44 | 2 | if ($config == null) { |
|
45 | 2 | $config = include 'config/database.php'; |
|
46 | 1 | } |
|
47 | |||
48 | try { |
||
49 | 2 | DatabaseConnection::makeConnection($config); |
|
50 | 2 | } catch (Exception $e) { |
|
51 | $this->logger->error('Exception: ' . $e->getMessage()); |
||
52 | } |
||
53 | 3 | } |
|
54 | |||
55 | 4 | $this->geo = new GeoFixer(); |
|
56 | 4 | } |
|
57 | |||
58 | /** |
||
59 | * Поиск похожих слов в массиве |
||
60 | * Логирование ошибок |
||
61 | * |
||
62 | * @param $word |
||
63 | * @param $search_array |
||
64 | * @param bool $strict_search |
||
65 | * |
||
66 | * @return string|false |
||
67 | */ |
||
68 | 3 | public function findSimilarWord($word, $search_array, $strict_search = false) |
|
69 | { |
||
70 | 3 | $this->geo->isStrict($strict_search); |
|
71 | |||
72 | 3 | $result = $this->geo->findSimilarWord($word, $search_array); |
|
73 | |||
74 | 3 | if ($result === false && $this->logger) { |
|
75 | $this->logger->warning('Не найдено похожее слово: ' . $word); |
||
76 | $this->logger->warning('Строгий режим: ' . (int) $strict_search); |
||
77 | $this->logger->warning('Массива для поиска: ' . implode($search_array, ', ') . PHP_EOL); |
||
78 | } |
||
79 | |||
80 | 3 | return $result; |
|
81 | } |
||
82 | |||
83 | /** |
||
84 | * Поиск кода региона в базе КЛАДР |
||
85 | * Логирование ошибок |
||
86 | * |
||
87 | * @param $region |
||
88 | * @param bool $first_letters |
||
89 | * @param bool $strict_search |
||
90 | * |
||
91 | * @return string|false |
||
92 | */ |
||
93 | 5 | public function findKladrRegion($region, $first_letters = false, $strict_search = false) |
|
94 | { |
||
95 | 4 | $this->geo = new GeoFixer(); |
|
96 | |||
97 | 4 | $result = $this->findFiasRegion($region, $first_letters, $strict_search); |
|
98 | |||
99 | 5 | if ($result !== false) { |
|
100 | 3 | return str_pad($result, 13, '0'); |
|
101 | } |
||
102 | |||
103 | 1 | return $result; |
|
104 | } |
||
105 | |||
106 | /** |
||
107 | * Поиск кода региона в базе ФИАС |
||
108 | * Логирование ошибок |
||
109 | * |
||
110 | * @param $region |
||
111 | * @param bool $first_letters |
||
112 | * @param bool $strict_search |
||
113 | * |
||
114 | * @return string|false |
||
115 | */ |
||
116 | 8 | public function findFiasRegion($region, $first_letters = false, $strict_search = false) |
|
117 | { |
||
118 | 8 | $this->geo = new GeoFixer(); |
|
119 | |||
120 | 8 | $this->geo->isStrict($strict_search); |
|
121 | 8 | $this->geo->isFirstLetters($first_letters); |
|
122 | |||
123 | 8 | $result = $this->geo->findFiasRegion($region); |
|
124 | |||
125 | 8 | if ($result === false && $this->logger) { |
|
126 | $this->logger->warning('Не найден регион ' . $region . ' в базе ФИАС'); |
||
127 | $this->logger->warning('Строгий режим: ' . (int) $strict_search); |
||
128 | $this->logger->warning('Режим "совпадают первые буквы": ' . (int) $first_letters . PHP_EOL); |
||
129 | } |
||
130 | |||
131 | 8 | return $result; |
|
132 | } |
||
133 | |||
134 | /** |
||
135 | * Поиск ID городов, или ID городов и поселений по коду региона в базе ФИАС |
||
136 | * Логирование ошибок |
||
137 | * |
||
138 | * @param $city |
||
139 | * @param $region_code |
||
140 | * @param bool $first_letters |
||
141 | * @param bool $strict_search |
||
142 | * |
||
143 | * @return string|false |
||
144 | */ |
||
145 | 4 | View Code Duplication | public function findFiasSettlement($city, $region_code, $first_letters = false, $strict_search = false, $full_settlements = false) |
146 | { |
||
147 | 4 | $this->geo = new GeoFixer(); |
|
148 | |||
149 | 4 | $this->geo->isStrict($strict_search); |
|
150 | 4 | $this->geo->isFirstLetters($first_letters); |
|
151 | 4 | $this->geo->isFullSettlements($full_settlements); |
|
152 | |||
153 | 4 | $result = $this->geo->findFiasSettlements($city, $region_code); |
|
154 | |||
155 | 4 | if ($result === false && $this->logger) { |
|
156 | $this->logger->warning('Не найден город ' . $city . ' в регионе с кодом ' . $region_code . ' базы ФИАС'); |
||
157 | $this->logger->warning('Строгий режим: ' . (int) $strict_search); |
||
158 | $this->logger->warning('Режим "совпадают первые буквы": ' . (int) $first_letters . PHP_EOL); |
||
159 | } |
||
160 | |||
161 | 4 | return $result; |
|
162 | } |
||
163 | |||
164 | /** |
||
165 | * Поиск ID городов, или ID городов и поселений по коду региона в базе КЛАДР |
||
166 | * Логирование ошибок |
||
167 | * |
||
168 | * @param $city |
||
169 | * @param $region_code |
||
170 | * @param bool $first_letters |
||
171 | * @param bool $strict_search |
||
172 | * |
||
173 | * @return string|false |
||
174 | */ |
||
175 | 5 | public function findKladrSettlement($city, $region_code, $first_letters = false, $strict_search = false, $full_settlements = false) |
|
176 | { |
||
177 | 4 | $this->geo = new GeoFixer(); |
|
178 | |||
179 | 4 | $this->geo->isStrict($strict_search); |
|
180 | 4 | $this->geo->isFirstLetters($first_letters); |
|
181 | 4 | $this->geo->isFullSettlements($full_settlements); |
|
182 | |||
183 | 4 | $region_code = substr($region_code, 0, 2); |
|
184 | |||
185 | 4 | $result = $this->geo->findKladrSettlements($city, $region_code); |
|
186 | |||
187 | 4 | if ($result === false && $this->logger) { |
|
188 | $this->logger->warning('Не найден город ' . $city . ' в регионе с кодом ' . $region_code . ' базы ФИАС'); |
||
189 | $this->logger->warning('Строгий режим: ' . (int) $strict_search); |
||
190 | $this->logger->warning('Режим "совпадают первые буквы": ' . (int) $first_letters . PHP_EOL); |
||
191 | } |
||
192 | |||
193 | 5 | return $result; |
|
194 | } |
||
195 | |||
196 | /** |
||
197 | * Поиск ID улицы по ID города в базе ФИАС |
||
198 | * Логирование ошибок |
||
199 | * |
||
200 | * @param $street |
||
201 | * @param $city_id |
||
202 | * @param bool $first_letters |
||
203 | * @param bool $strict_search |
||
204 | * |
||
205 | * @return string|false |
||
206 | */ |
||
207 | 3 | View Code Duplication | public function findFiasStreet($street, $city_id, $first_letters = false, $strict_search = false) |
208 | { |
||
209 | 3 | $this->geo = new GeoFixer(); |
|
210 | |||
211 | 3 | $this->geo->isStrict($strict_search); |
|
212 | 3 | $this->geo->isFirstLetters($first_letters); |
|
213 | |||
214 | 3 | $result = $this->geo->findFiasStreets($street, $city_id); |
|
215 | |||
216 | 3 | if ($result === false && $this->logger) { |
|
217 | $this->logger->warning('Не найдена улица ' . $street . ' в городе с id ' . $city_id . ' базы ФИАС'); |
||
218 | $this->logger->warning('Строгий режим: ' . (int) $strict_search); |
||
219 | $this->logger->warning('Режим "совпадают первые буквы": ' . (int) $first_letters . PHP_EOL); |
||
220 | } |
||
221 | |||
222 | 3 | return $result; |
|
223 | } |
||
224 | |||
225 | /** |
||
226 | * Поиск кода улицы по коду города в базе КЛАДР |
||
227 | * Логирование ошибок |
||
228 | * |
||
229 | * @param $street |
||
230 | * @param $city_code |
||
231 | * @param bool $first_letters |
||
232 | * @param bool $strict_search |
||
233 | * |
||
234 | * @return string|false |
||
235 | */ |
||
236 | 4 | View Code Duplication | public function findKladrStreet($street, $city_code, $first_letters = false, $strict_search = false) |
237 | { |
||
238 | 4 | $this->geo = new GeoFixer(); |
|
239 | |||
240 | 4 | $this->geo->isStrict($strict_search); |
|
241 | 4 | $this->geo->isFirstLetters($first_letters); |
|
242 | |||
243 | 4 | $result = $this->geo->findKladrStreets($street, $city_code); |
|
244 | |||
245 | 4 | if ($result === false && $this->logger) { |
|
246 | $this->logger->warning('Не найдена улица ' . $street . ' в городе с кодом ' . $city_code . ' базы КЛАДР'); |
||
247 | $this->logger->warning('Строгий режим: ' . (int) $strict_search); |
||
248 | $this->logger->warning('Режим "совпадают первые буквы": ' . (int) $first_letters . PHP_EOL); |
||
249 | } |
||
250 | |||
251 | 4 | return $result; |
|
252 | } |
||
253 | |||
254 | |||
255 | /** |
||
256 | * Поиск ID дома по ID улицы в базе ФИАС |
||
257 | * |
||
258 | * @param $house |
||
259 | * @param $street_id |
||
260 | * @param bool $building |
||
261 | * |
||
262 | * @return string|false |
||
263 | */ |
||
264 | 4 | public function findFiasHouse($house, $street_id, $building = false) |
|
265 | { |
||
266 | 4 | $this->geo = new GeoFixer(); |
|
267 | |||
268 | 4 | $result = $this->geo->findFiasHouses($house, $street_id, $building); |
|
269 | |||
270 | 4 | if ($result === false && $this->logger) { |
|
271 | if ($building) { |
||
272 | $this->logger->warning('Не найден дом ' . $house . ', корпус ' . $building . ' на улице с id ' . $street_id . ' базы ФИАС' . PHP_EOL); |
||
273 | } else { |
||
274 | $this->logger->warning('Не найден дом ' . $house . ' на улице с id ' . $street_id . ' базы ФИАС: ' . $house . PHP_EOL); |
||
275 | } |
||
276 | } |
||
277 | |||
278 | 4 | return $result; |
|
279 | } |
||
280 | } |
||
281 |
Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.
Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..