Geocoder\Provider\Yandex::executeQuery PHP Méthode

executeQuery() private méthode

private executeQuery ( string $query )
$query string
    private function executeQuery($query)
    {
        if (null !== $this->getLocale()) {
            $query = sprintf('%s&lang=%s', $query, str_replace('_', '-', $this->getLocale()));
        }
        $query = sprintf('%s&results=%d', $query, $this->getLimit());
        $request = $this->getMessageFactory()->createRequest('GET', $query);
        $content = (string) $this->getHttpClient()->sendRequest($request)->getBody();
        $json = (array) json_decode($content, true);
        if (empty($json) || isset($json['error']) || isset($json['response']) && '0' === $json['response']['GeoObjectCollection']['metaDataProperty']['GeocoderResponseMetaData']['found']) {
            throw new NoResult(sprintf('Could not execute query "%s".', $query));
        }
        $data = $json['response']['GeoObjectCollection']['featureMember'];
        $results = [];
        foreach ($data as $item) {
            $bounds = null;
            $details = array('pos' => ' ');
            array_walk_recursive($item['GeoObject'], function ($value, $key) use(&$details) {
                $details[$key] = $value;
            });
            if (!empty($details['lowerCorner'])) {
                $coordinates = explode(' ', $details['lowerCorner']);
                $bounds['south'] = (double) $coordinates[1];
                $bounds['west'] = (double) $coordinates[0];
            }
            if (!empty($details['upperCorner'])) {
                $coordinates = explode(' ', $details['upperCorner']);
                $bounds['north'] = (double) $coordinates[1];
                $bounds['east'] = (double) $coordinates[0];
            }
            $coordinates = explode(' ', $details['pos']);
            $adminLevels = [];
            foreach (['AdministrativeAreaName', 'SubAdministrativeAreaName'] as $i => $detail) {
                if (isset($details[$detail])) {
                    $adminLevels[] = ['name' => $details[$detail], 'level' => $i + 1];
                }
            }
            $results[] = array_merge($this->getDefaults(), array('latitude' => (double) $coordinates[1], 'longitude' => (double) $coordinates[0], 'bounds' => $bounds, 'streetNumber' => isset($details['PremiseNumber']) ? $details['PremiseNumber'] : null, 'streetName' => isset($details['ThoroughfareName']) ? $details['ThoroughfareName'] : null, 'subLocality' => isset($details['DependentLocalityName']) ? $details['DependentLocalityName'] : null, 'locality' => isset($details['LocalityName']) ? $details['LocalityName'] : null, 'adminLevels' => $adminLevels, 'country' => isset($details['CountryName']) ? $details['CountryName'] : null, 'countryCode' => isset($details['CountryNameCode']) ? $details['CountryNameCode'] : null));
        }
        return $this->returnResults($results);
    }