Completed
Push — master ( d6e5b5...111799 )
by Konstantin
01:37
created

index.php (1 issue)

Severity

Upgrade to new PHP Analysis Engine

These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more

1
<?php
2
3
/* Инициализация приложения */
4
5
require_once dirname(__FILE__) . '/vendor/autoload.php';
6
7
$geo = new \GeoFixer\GeoFixerFacade($fias = true);
8
9
/* -------------------------------------------------------------------- */
10
11
/* Поиск по имеющимся массивам */
12
13
/* массив, где нужно найти регион/город */
14
$find_in = ['Москва', 'Екатеринбург', 'Томск'];
15
16
/* регион или город, поступивший от пользователя */
17
$find_to = 'город Москва';
18
19
/* вернется регион или город из массива $find_in,
20
 максимально подходящий под строку $find_to */
21
$result = $geo->findSimilarWord($find_to, $find_in);
22
23
/* если нужен более строгий отбор,
24
то нужно добавить третий параметр */
25
$result = $geo->findSimilarWord($find_to, $find, $strict_search = true);
26
27
/* -------------------------------------------------------------------- */
28
29
/** Поиск кода региона по базе ФИАС */
30
31
$region = 'Ленинрадская область';
32
33
/* вернется id региона или false */
34
$code = $geo->findFiasRegion($region);
35
36
/* Возможны дополнительные параметры: */
37
38
/* кол-во первых букв в регионе, которые должны совпадать */
39
$first_letters = 2;
40
$code = $geo->findFiasRegion($region, $first_letters,  $strict_search = true);
0 ignored issues
show
$first_letters is of type integer, but the function expects a boolean.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
41
42
/* -------------------------------------------------------------------- */
43
44
/* Поиск ID города по коду региона ФИАС */
45
46
$first_letters = false;
47
$strict_search = false;
48
$full_settlements = true; // поиск не только по городам, но и по поселениям
49
50
$city = 'Благовещенск';
51
$region_code = 28;
52
53
$id = $geo->findFiasSettlement($city, $region_code, $first_letters, $strict_search, $full_settlements);
54
55
/* -------------------------------------------------------------------- */
56
57
/* Поиск ID улицы по ID города */
58
59
$first_letters = false;
60
$strict_search = false;
61
62
$street = 'Амурская';
63
$city_id = '8f41253d-6e3b-48a9-842a-25ba894bd093';
64
65
$id = $geo->findFiasStreet($street, $city_id, $first_letters, $strict_search);
66
67
/* -------------------------------------------------------------------- */
68
69
/* Поиск ID дома по ID улицы */
70
71
$street_id = '3e0d1213-1212-4f87-bdd3-5f8ef6f6473e';
72
$house = 261;
73
$building = false; // если нужно, можно указать корпус
74
75
$id = $geo->findFiasHouse($house, $street_id, $building);
76
77
/* -------------------------------------------------------------------- */
78
79