| 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 array $config | 
            
                                                                                                            
                            
            
                                    
            
            
                | 33 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 34 | 3 |  |     public function __construct($fias = false, $config = null) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 35 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 36 | 3 |  |         $this->logger = new KLogger\Logger(dirname(dirname(__FILE__)) . '/logs'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 37 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 38 | 3 |  |         if ($fias === true) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 39 | 2 |  |             if ($config == null) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 40 | 1 |  |                 $config = include 'config/database.php'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 41 | 1 |  |             } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 42 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 43 |  |  |             try { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 44 | 2 |  |                 DatabaseConnection::makeConnection($config); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 45 | 2 |  |             } catch (Exception $e) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 46 |  |  |                 $this->logger->error('Exception: ' . $e->getMessage()); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 47 |  |  |             } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 48 | 2 |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 49 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 50 | 3 |  |         $this->geo = new GeoFixer(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 51 | 3 |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 52 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 53 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 54 |  |  |      * Поиск похожих слов в массиве | 
            
                                                                                                            
                            
            
                                    
            
            
                | 55 |  |  |      * Логирование ошибок | 
            
                                                                                                            
                            
            
                                    
            
            
                | 56 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 57 |  |  |      * @param $word | 
            
                                                                                                            
                            
            
                                    
            
            
                | 58 |  |  |      * @param $search_array | 
            
                                                                                                            
                            
            
                                    
            
            
                | 59 |  |  |      * @param bool $strict_search | 
            
                                                                                                            
                            
            
                                    
            
            
                | 60 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 61 |  |  |      * @return string|false | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 62 |  |  |      */ | 
            
                                                                        
                            
            
                                                                    
                                                                                                        
            
            
                | 63 | 3 | View Code Duplication |     public function findSimilarWord($word, $search_array, $strict_search = false) | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                        
                            
            
                                    
            
            
                | 64 |  |  |     { | 
            
                                                                        
                            
            
                                    
            
            
                | 65 | 3 |  |         $this->geo->isStrict($strict_search); | 
            
                                                                        
                            
            
                                    
            
            
                | 66 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 67 | 3 |  |         $result = $this->geo->findSimilarWord($word, $search_array); | 
            
                                                                        
                            
            
                                    
            
            
                | 68 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 69 | 3 |  |         if ($result === false) { | 
            
                                                                        
                            
            
                                    
            
            
                | 70 | 1 |  |             $this->logger->warning('Не найдено похожее слово: ' . $word); | 
            
                                                                        
                            
            
                                    
            
            
                | 71 | 1 |  |             $this->logger->warning('Строгий режим: ' . (int) $strict_search); | 
            
                                                                        
                            
            
                                    
            
            
                | 72 | 1 |  |             $this->logger->warning('Массива для поиска: ' . implode($search_array, ', ') . PHP_EOL); | 
            
                                                                        
                            
            
                                    
            
            
                | 73 | 1 |  |         } | 
            
                                                                        
                            
            
                                    
            
            
                | 74 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 75 | 3 |  |         return $result; | 
            
                                                                        
                            
            
                                    
            
            
                | 76 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 77 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 78 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 79 |  |  |      * Поиск кода региона в базе КЛАДР | 
            
                                                                                                            
                            
            
                                    
            
            
                | 80 |  |  |      * Логирование ошибок | 
            
                                                                                                            
                            
            
                                    
            
            
                | 81 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 82 |  |  |      * @param $region | 
            
                                                                                                            
                            
            
                                    
            
            
                | 83 |  |  |      * @param bool $first_letters | 
            
                                                                                                            
                            
            
                                    
            
            
                | 84 |  |  |      * @param bool $strict_search | 
            
                                                                                                            
                            
            
                                    
            
            
                | 85 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 86 |  |  |      * @return string|false | 
            
                                                                                                            
                            
            
                                    
            
            
                | 87 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 88 | 4 |  |     public function findKladrRegion($region, $first_letters = false, $strict_search = false) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 89 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 90 | 4 |  |         $result = $this->findFiasRegion($region, $first_letters, $strict_search); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 91 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 92 | 4 |  |         if ($result !== false) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 93 | 3 |  |             return str_pad($result, 13, '0'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 94 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 95 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 96 | 1 |  |         return $result; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 97 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 98 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 99 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 100 |  |  |      * Поиск кода региона в базе ФИАС | 
            
                                                                                                            
                            
            
                                    
            
            
                | 101 |  |  |      * Логирование ошибок | 
            
                                                                                                            
                            
            
                                    
            
            
                | 102 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 103 |  |  |      * @param $region | 
            
                                                                                                            
                            
            
                                    
            
            
                | 104 |  |  |      * @param bool $first_letters | 
            
                                                                                                            
                            
            
                                    
            
            
                | 105 |  |  |      * @param bool $strict_search | 
            
                                                                                                            
                            
            
                                    
            
            
                | 106 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 107 |  |  |      * @return string|false | 
            
                                                                                                            
                            
            
                                    
            
            
                | 108 |  |  |      */ | 
            
                                                                                                            
                            
            
                                                                    
                                                                                                        
            
            
                | 109 | 8 | View Code Duplication |     public function findFiasRegion($region, $first_letters = false, $strict_search = false) | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 110 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 111 | 8 |  |         $this->geo->isStrict($strict_search); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 112 | 8 |  |         $this->geo->isFirstLetters($first_letters); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 113 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 114 | 8 |  |         $result = $this->geo->findFiasRegion($region); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 115 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 116 | 8 |  |         if ($result === false) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 117 | 2 |  |             $this->logger->warning('Не найден регион ' . $region . ' в базе ФИАС'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 118 | 2 |  |             $this->logger->warning('Строгий режим: ' . (int) $strict_search); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 119 | 2 |  |             $this->logger->warning('Режим "совпадают первые буквы": ' . (int) $first_letters . PHP_EOL); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 120 | 2 |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 121 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 122 | 8 |  |         return $result; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 123 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 124 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 125 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 126 |  |  |      * Поиск ID городов, или ID городов и поселений по коду региона в базе ФИАС | 
            
                                                                                                            
                            
            
                                    
            
            
                | 127 |  |  |      * Логирование ошибок | 
            
                                                                                                            
                            
            
                                    
            
            
                | 128 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 129 |  |  |      * @param $city | 
            
                                                                                                            
                            
            
                                    
            
            
                | 130 |  |  |      * @param $region_code | 
            
                                                                                                            
                            
            
                                    
            
            
                | 131 |  |  |      * @param bool $first_letters | 
            
                                                                                                            
                            
            
                                    
            
            
                | 132 |  |  |      * @param bool $strict_search | 
            
                                                                                                            
                            
            
                                    
            
            
                | 133 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 134 |  |  |      * @return string|false | 
            
                                                                                                            
                            
            
                                    
            
            
                | 135 |  |  |      */ | 
            
                                                                                                            
                            
            
                                                                    
                                                                                                        
            
            
                | 136 | 4 | View Code Duplication |     public function findFiasSettlement($city, $region_code, $first_letters = false, $strict_search = false, $full_settlements = false) | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 137 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 138 | 4 |  |         $this->geo->isStrict($strict_search); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 139 | 4 |  |         $this->geo->isFirstLetters($first_letters); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 140 | 4 |  |         $this->geo->isFullSettlements($full_settlements); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 141 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 142 | 4 |  |         $result = $this->geo->findFiasSettlements($city, $region_code); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 143 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 144 | 4 |  |         if ($result === false) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 145 | 1 |  |             $this->logger->warning('Не найден город ' . $city . ' в регионе с кодом ' . $region_code . ' базы ФИАС'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 146 | 1 |  |             $this->logger->warning('Строгий режим: ' . (int) $strict_search); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 147 | 1 |  |             $this->logger->warning('Режим "совпадают первые буквы": ' . (int) $first_letters . PHP_EOL); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 148 | 1 |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 149 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 150 | 4 |  |         return $result; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 151 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 152 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 153 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 154 |  |  |      * Поиск ID городов, или ID городов и поселений по коду региона в базе КЛАДР | 
            
                                                                                                            
                            
            
                                    
            
            
                | 155 |  |  |      * Логирование ошибок | 
            
                                                                                                            
                            
            
                                    
            
            
                | 156 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 157 |  |  |      * @param $city | 
            
                                                                                                            
                            
            
                                    
            
            
                | 158 |  |  |      * @param $region_code | 
            
                                                                                                            
                            
            
                                    
            
            
                | 159 |  |  |      * @param bool $first_letters | 
            
                                                                                                            
                            
            
                                    
            
            
                | 160 |  |  |      * @param bool $strict_search | 
            
                                                                                                            
                            
            
                                    
            
            
                | 161 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 162 |  |  |      * @return string|false | 
            
                                                                                                            
                            
            
                                    
            
            
                | 163 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 164 | 4 |  |     public function findKladrSettlement($city, $region_code, $first_letters = false, $strict_search = false, $full_settlements = false) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 165 | 1 |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 166 | 4 |  |         $this->geo->isStrict($strict_search); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 167 | 4 |  |         $this->geo->isFirstLetters($first_letters); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 168 | 4 |  |         $this->geo->isFullSettlements($full_settlements); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 169 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 170 | 4 |  |         $region_code = substr($region_code, 0, 2); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 171 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 172 | 4 |  |         $result = $this->geo->findKladrSettlements($city, $region_code); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 173 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 174 | 4 |  |         if ($result === false) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 175 | 1 |  |             $this->logger->warning('Не найден город ' . $city . ' в регионе с кодом ' . $region_code . ' базы ФИАС'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 176 | 1 |  |             $this->logger->warning('Строгий режим: ' . (int) $strict_search); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 177 | 1 |  |             $this->logger->warning('Режим "совпадают первые буквы": ' . (int) $first_letters . PHP_EOL); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 178 | 1 |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 179 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 180 | 4 |  |         return $result; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 181 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 182 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 183 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 184 |  |  |      * Поиск ID улицы по ID города в базе ФИАС | 
            
                                                                                                            
                            
            
                                    
            
            
                | 185 |  |  |      * Логирование ошибок | 
            
                                                                                                            
                            
            
                                    
            
            
                | 186 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 187 |  |  |      * @param $street | 
            
                                                                                                            
                            
            
                                    
            
            
                | 188 |  |  |      * @param $city_id | 
            
                                                                                                            
                            
            
                                    
            
            
                | 189 |  |  |      * @param bool $first_letters | 
            
                                                                                                            
                            
            
                                    
            
            
                | 190 |  |  |      * @param bool $strict_search | 
            
                                                                                                            
                            
            
                                    
            
            
                | 191 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 192 |  |  |      * @return string|false | 
            
                                                                                                            
                            
            
                                    
            
            
                | 193 |  |  |      */ | 
            
                                                                                                            
                            
            
                                                                    
                                                                                                        
            
            
                | 194 | 3 | View Code Duplication |     public function findFiasStreet($street, $city_id, $first_letters = false, $strict_search = false) | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 195 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 196 | 3 |  |         $this->geo->isStrict($strict_search); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 197 | 3 |  |         $this->geo->isFirstLetters($first_letters); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 198 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 199 | 3 |  |         $result = $this->geo->findFiasStreets($street, $city_id); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 200 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 201 | 3 |  |         if ($result === false) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 202 | 1 |  |             $this->logger->warning('Не найдена улица ' . $street . ' в городе с id ' . $city_id . ' базы ФИАС'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 203 | 1 |  |             $this->logger->warning('Строгий режим: ' . (int) $strict_search); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 204 | 1 |  |             $this->logger->warning('Режим "совпадают первые буквы": ' . (int) $first_letters . PHP_EOL); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 205 | 1 |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 206 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 207 | 3 |  |         return $result; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 208 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 209 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 210 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 211 |  |  |      * Поиск кода улицы по коду города в базе КЛАДР | 
            
                                                                                                            
                            
            
                                    
            
            
                | 212 |  |  |      * Логирование ошибок | 
            
                                                                                                            
                            
            
                                    
            
            
                | 213 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 214 |  |  |      * @param $street | 
            
                                                                                                            
                            
            
                                    
            
            
                | 215 |  |  |      * @param $city_code | 
            
                                                                                                            
                            
            
                                    
            
            
                | 216 |  |  |      * @param bool $first_letters | 
            
                                                                                                            
                            
            
                                    
            
            
                | 217 |  |  |      * @param bool $strict_search | 
            
                                                                                                            
                            
            
                                    
            
            
                | 218 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 219 |  |  |      * @return string|false | 
            
                                                                                                            
                            
            
                                    
            
            
                | 220 |  |  |      */ | 
            
                                                                                                            
                            
            
                                                                    
                                                                                                        
            
            
                | 221 | 3 | View Code Duplication |     public function findKladrStreet($street, $city_code, $first_letters = false, $strict_search = false) | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 222 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 223 | 3 |  |         $this->geo->isStrict($strict_search); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 224 | 3 |  |         $this->geo->isFirstLetters($first_letters); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 225 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 226 | 3 |  |         $result = $this->geo->findKladrStreets($street, $city_code); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 227 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 228 | 3 |  |         if ($result === false) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 229 | 1 |  |             $this->logger->warning('Не найдена улица ' . $street . ' в городе с кодом ' . $city_code . ' базы КЛАДР'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 230 | 1 |  |             $this->logger->warning('Строгий режим: ' . (int) $strict_search); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 231 | 1 |  |             $this->logger->warning('Режим "совпадают первые буквы": ' . (int) $first_letters . PHP_EOL); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 232 | 1 |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 233 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 234 | 3 |  |         return $result; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 235 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 236 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 237 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 238 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 239 |  |  |      * Поиск ID дома по ID улицы в базе ФИАС | 
            
                                                                                                            
                            
            
                                    
            
            
                | 240 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 241 |  |  |      * @param $house | 
            
                                                                                                            
                            
            
                                    
            
            
                | 242 |  |  |      * @param $street_id | 
            
                                                                                                            
                            
            
                                    
            
            
                | 243 |  |  |      * @param bool $building | 
            
                                                                                                            
                            
            
                                    
            
            
                | 244 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 245 |  |  |      * @return string|false | 
            
                                                                                                            
                            
            
                                    
            
            
                | 246 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 247 | 4 |  |     public function findFiasHouse($house, $street_id, $building = false) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 248 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 249 | 4 |  |         $result = $this->geo->findFiasHouses($house, $street_id, $building); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 250 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 251 | 4 |  |         if ($result === false) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 252 | 2 |  |             if ($building) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 253 | 1 |  |                 $this->logger->warning('Не найден дом ' . $house . ', корпус ' . $building . ' на улице с id ' . $street_id . ' базы ФИАС' . PHP_EOL); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 254 | 1 |  |             } else { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 255 | 1 |  |                 $this->logger->warning('Не найден дом ' . $house . ' на улице с id ' . $street_id . ' базы ФИАС: ' . $house . PHP_EOL); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 256 |  |  |             } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 257 | 2 |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 258 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 259 | 4 |  |         return $result; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 260 |  |  |     } | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 261 |  |  | } | 
            
                                                        
            
                                    
            
            
                | 262 |  |  |  | 
            
                        
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.
You can also find more detailed suggestions in the “Code” section of your repository.