Полный ответ yandex api

@param $address

@return array
323777
static public function getYandexData($addressString)
    {
        $request    = (new Client([
                            'formatters' =>
                            [
                                Client::FORMAT_JSON => JsonFormatter::class
                            ]
                        ]))->createRequest()
                        ->setUrl("https://geocode-maps.yandex.ru/1.x/?geocode={$addressString}&format=json")
                        ->setOptions([
                            'timeout' => 1
                        ])
        ;
        $response = $request->send();

        if ($response->isOk)
        {
            return (array) $response->data;
        }

        return [];
    }
531444
public function addAddress($address)
    {
        if (!$this->getAddresses()) {
            return $this->setAddresses(array($address));
        } else {
            return $this->setAddresses(
                array_merge($this->getAddresses(), array($address))
            );
        }
    }
1111202
private function lookupIP($address)
    {
        // Create the responses storage array
        $responses = [];

        // Query every server in the IP list
        foreach ($this->servers->ip as $server) {
            // Check if we haven't queried this server yet
            if (array_key_exists($server, $responses)) {
                continue;
            }

            // Query the server
            $responses[$server] = $this->query($address, $server);
        }

        // Create a result object
        $result = new Result();

        // Set target
        $result->target = $address;

        // Set the type
        $result->type = 'ip';

        // Set response count
        $result->count = count($responses);

        // Set responses
        $result->responses = array_reverse($responses);

        // Return the Result object
        return $result;
    }
1222343
protected function _splitAddresses($address)
    {
        if (!empty($this->limit) && count($this->addresses) == $this->limit) {
            return '';
        }

        if ($this->_isGroup($address) && !isset($this->error)) {
            $split_char = ';';
            $is_group   = true;
        } elseif (!isset($this->error)) {
            $split_char = ',';
            $is_group   = false;
        } elseif (isset($this->error)) {
            return false;
        }

        // Split the string based on the above ten or so lines.
        $parts  = explode($split_char, $address);
        $string = $this->_splitCheck($parts, $split_char);

        // If a group...
        if ($is_group) {
            // If $string does not contain a colon outside of
            // brackets/quotes etc then something's fubar.

            // First check there's a colon at all:
            if (strpos($string, ':') === false) {
                $this->error = 'Invalid address: ' . $string;
                return false;
            }

            // Now check it's outside of brackets/quotes:
            if (!$this->_splitCheck(explode(':', $string), ':')) {
                return false;
            }

            // We must have a group at this point, so increase the counter:
            $this->num_groups++;
        }

        // $string now contains the first full address/group.
        // Add to the addresses array.
        $this->addresses[] = array(
                                   'address' => trim($string),
                                   'group'   => $is_group
                                   );

        // Remove the now stored address from the initial line, the +1
        // is to account for the explode character.
        $address = trim(substr($address, strlen($string) + 1));

        // If the next char is a comma and this was a group, then
        // there are more addresses, otherwise, if there are any more
        // chars, then there is another address.
        if ($is_group && substr($address, 0, 1) == ','){
            $address = trim(substr($address, 1));
            return $address;

        } elseif (strlen($address) > 0) {
            return $address;

        } else {
            return '';
        }

        // If you got here then something's off
        return false;
    }
887901
protected function _formatAddress($address)
    {
        $return = [];
        foreach ($address as $email => $alias) {
            if ($email === $alias) {
                $return[] = $email;
            } else {
                $encoded = $this->_encode($alias);
                if ($encoded === $alias && preg_match('/[^a-z0-9 ]/i', $encoded)) {
                    $encoded = '"' . str_replace('"', '\"', $encoded) . '"';
                }
                $return[] = sprintf('%s <%s>', $encoded, $email);
            }
        }

        return $return;
    }
918155
private function _generatorAddressCode($address)
    {
        $addressCode = array_search($address, $this->_addressCodeList);
        $classification = $this->_addressCodeClassification($addressCode);
        switch ($classification) {
            case 'country':
                $pattern = '/\d{4}(?!00)[0-9]{2}$/';
                $addressCode = $this->_getRandAddressCode($pattern);
                break;
            case 'province':
                $provinceCode = substr($addressCode, 0, 2);
                $pattern = '/^'.$provinceCode.'\d{2}(?!00)[0-9]{2}$/';
                $addressCode = $this->_getRandAddressCode($pattern);
                break;
            case 'city':
                $cityCode = substr($addressCode, 0, 4);
                $pattern = '/^'.$cityCode.'(?!00)[0-9]{2}$/';
                $addressCode = $this->_getRandAddressCode($pattern);
                break;
        }

        return $addressCode;
    }
445727
protected function formatAddress($address, $port)
    {
        if ($port !== 0) {
            if (strpos($address, ':') !== false) {
                $address = '[' . $address . ']';
            }
            $address .= ':' . $port;
        }
        return $address;
    }
565116
public function trimAddress($address)
    {
        $address = trim($address);

        return (($address[0] == '<') && (substr($address, -1) == '>'))
            ? substr($address, 1, -1)
            : $address;
    }
128058
protected function getItemMarkerArray($address)
    {
        $markerArray = [];

        //local configuration and local cObj
        $lConf = $this->conf['templates.'][$this->conf['templateName'] . '.'];
        $lcObj = GeneralUtility::makeInstance(ContentObjectRenderer::class);
        $lcObj->data = $address;

        $markerArray['###UID###'] = $address['uid'];

        $markerArray['###GENDER###'] = $lcObj->stdWrap($address['gender'], $lConf['gender.']);
        $markerArray['###NAME###'] = $lcObj->stdWrap($address['name'], $lConf['name.']);
        $markerArray['###FIRSTNAME###'] = $lcObj->stdWrap($address['first_name'], $lConf['first_name.']);
        $markerArray['###MIDDLENAME###'] = $lcObj->stdWrap($address['middle_name'], $lConf['middle_name.']);
        $markerArray['###LASTNAME###'] = $lcObj->stdWrap($address['last_name'], $lConf['last_name.']);
        $markerArray['###TITLE###'] = $lcObj->stdWrap($address['title'], $lConf['title.']);
        $markerArray['###EMAIL###'] = $lcObj->stdWrap($address['email'], $lConf['email.']);
        $markerArray['###PHONE###'] = $lcObj->stdWrap($address['phone'], $lConf['phone.']);
        $markerArray['###FAX###'] = $lcObj->stdWrap($address['fax'], $lConf['fax.']);
        $markerArray['###MOBILE###'] = $lcObj->stdWrap($address['mobile'], $lConf['mobile.']);
        $markerArray['###WWW###'] = $lcObj->stdWrap($address['www'], $lConf['www.']);
        $markerArray['###ADDRESS###'] = $lcObj->stdWrap($address['address'], $lConf['address.']);
        $markerArray['###BUILDING###'] = $lcObj->stdWrap($address['building'], $lConf['building.']);
        $markerArray['###ROOM###'] = $lcObj->stdWrap($address['room'], $lConf['room.']);
        $markerArray['###BIRTHDAY###'] = $lcObj->stdWrap($address['birthday'], $lConf['birthday.']);
        $markerArray['###ORGANIZATION###'] = $lcObj->stdWrap($address['company'], $lConf['organization.']);
        $markerArray['###COMPANY###'] = $markerArray['###ORGANIZATION###']; // alias
        $markerArray['###POSITION###'] = $lcObj->stdWrap($address['position'], $lConf['position.']);
        $markerArray['###CITY###'] = $lcObj->stdWrap($address['city'], $lConf['city.']);
        $markerArray['###ZIP###'] = $lcObj->stdWrap($address['zip'], $lConf['zip.']);
        $markerArray['###REGION###'] = $lcObj->stdWrap($address['region'], $lConf['region.']);
        $markerArray['###COUNTRY###'] = $lcObj->stdWrap($address['country'], $lConf['country.']);
        $markerArray['###DESCRIPTION###'] = $lcObj->stdWrap($address['description'], $lConf['description.']);
        $markerArray['###SKYPE###'] = $lcObj->stdWrap($address['skype'], $lConf['skype.']);
        $markerArray['###TWITTER###'] = $lcObj->stdWrap($address['twitter'], $lConf['twitter.']);
        $markerArray['###FACEBOOK###'] = $lcObj->stdWrap($address['facebook'], $lConf['facebook.']);
        $markerArray['###LINKEDIN###'] = $lcObj->stdWrap($address['linkedin'], $lConf['linkedin.']);
        $markerArray['###MAINGROUP###'] = $lcObj->stdWrap($address['groups'][0]['title'], $lConf['mainGroup.']);
        $markerArray['###GROUPLIST###'] = $lcObj->stdWrap($address['groupList'], $lConf['groupList.']);

        // the image
        $markerArray['###IMAGE###'] = '';
        if (!empty($address['image'])) {
            $filesConf = [
                'references.' => [
                    'uid' => (int)$address['uid'],
                    'table' => 'tt_address',
                    'fieldName' => 'image'
                ],
                'begin' => '0',
                'maxItems' => '1',

                'renderObj' => 'IMAGE',
                'renderObj.' => [
                    'file.' => [
                        'import.' => [
                            'data' => 'file:current:uid'
                        ],
                        'treatIdAsReference' => '1'
                    ],
                    'altText.' => [
                        'data' => 'file:current:alternative'
                    ],
                    'titleText.' => [
                        'data' => 'file:current:title'
                    ]
                ]
            ];
            if (is_array($lConf['image.'])) {
                $filesConf['renderObj.'] = array_merge_recursive($filesConf['renderObj.'], $lConf['image.']);
            }
            for ($filesIndex = 0; $filesIndex < 6; $filesIndex++) {
                $filesConf['begin'] = $filesIndex;
                $markerArray['###IMAGE' . ($filesIndex == 0 ? '' : $filesIndex) . '###'] = $lcObj->cObjGetSingle('FILES',
                    $filesConf);
            }
        } elseif (!empty($lConf['placeholderImage'])) {
            // we have no image, but a default image
            $iConf = $lConf['image.'];
            $iConf['file'] = $lcObj->stdWrap($lConf['placeholderImage'], $lConf['placeholderImage.']);
            $iConf['altText'] = !empty($iConf['altText']) ? $iConf['altText'] : $address['name'];
            $iConf['titleText'] = !empty($iConf['titleText']) ? $iConf['titleText'] : $address['name'];

            $markerArray['###IMAGE###'] = $lcObj->cObjGetSingle('IMAGE', $iConf);
        }

        // adds hook for processing of extra item markers
        if (\is_array($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['tt_address']['extraItemMarkerHook'])) {
            foreach ($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['tt_address']['extraItemMarkerHook'] as $_classRef) {
                $_procObj = GeneralUtility::makeInstance($_classRef);
                $markerArray = $_procObj->extraItemMarkerProcessor($markerArray, $address, $lConf, $this);
            }
        }

        return $markerArray;
    }
97330
protected function parseAddress(array $addresses)
    {
        return array_map(function ($address) {
            return (object) [
                'address' => $address->mailbox.'@'.$address->host,
                'domain' => $address->host,
                'name' => isset($address->personal)
                    ? static::convertBodyEncoding($address->personal)
                    : null
            ];
        }, array_filter($addresses, function ($address) {
            return property_exists($address, 'mailbox') && strtolower($address->mailbox) !== 'undisclosed-recipients';
        }));
    }
280818
private function checkIfAddressExists($address)
    {
        $oldAddress = $this->addressRepository->findOneByEmailIgnoreHidden( $address );

        return isset($oldAddress) && $oldAddress ? $oldAddress : null;
    }
200485
protected function setAddress($address)
    {
        if (is_array($address)) {
            $new_address = [];

            foreach (['address', 'city', 'state', 'zip'] as $field) {
                if (array_key_exists($field, $address)) {
                    $new_address[] = $address[$field];
                }
            }

            $address = implode(' ', $new_address);
        }

        return $address;
    }
483738
public function getTranslated(array $address, $both = false)
    {
        $default = $this->country->getDefaultFormat();
        $format = gplcart_array_merge($default, $address['country_format']);

        gplcart_array_sort($format);

        $results = array();
        foreach ($format as $key => $data) {

            if (!array_key_exists($key, $address) || empty($data['status'])) {
                continue;
            }

            if ($key === 'country') {
                $address[$key] = $address['country_native_name'];
            }

            if ($key === 'state_id') {
                $address[$key] = $address['state_name'];
            }

            if ($key === 'city_id' && !empty($address['city_name'])) {
                $address[$key] = $address['city_name'];
            }

            if ($both) {
                $results[$data['name']] = $address[$key];
                continue;
            }

            $results[$key] = $address[$key];
        }

        return array_filter($results);
    }
7601
public static function lookUpHostIp($address)
    {

        $ipAddress = null;
        if (function_exists('dns_get_record')) {
            $records = dns_get_record(trim($address));
            foreach ($records as $record) {
                if ($record['type'] == 'A') {
                    $ipAddress = $record['ip'];
                }
            }
        }
        return $ipAddress;
    }
249448
public function checkAddress($address)
    {
        $addr = $this->decodeBase58($address);
        if (strlen($addr) != 50) {
            return false;
        }
        $check = substr($addr, 0, strlen($addr) - 8);
        $check = pack('H*', $check);
        $check = strtoupper(hash('sha256', hash('sha256', $check, true)));
        $check = substr($check, 0, 8);

        return $check == substr($addr, strlen($addr) - 8);
    }
186235
public function getIpNumberFromAddress($address)
    {
        // Unrecognised addresses cause PHP warnings, silence the warning and return a bool instead
        $pton = @inet_pton($address);
        if (!$pton) {
            return false;
        }

        $number = '';
        foreach (unpack('C*', $pton) as $byte) {
            $number .= str_pad(decbin($byte), 8, '0', STR_PAD_LEFT);
        }

        return base_convert(ltrim($number, '0'), 2, 10);
    }
465266
public function render($address) {
    $element = [
      '#prefix' => '<p class="address" translate="no">',
      '#suffix' => '</p>',
      '#post_render' => [
        [get_class($this), 'postRender'],
      ],
      '#cache' => [
        'contexts' => [
          'languages:' . LanguageInterface::TYPE_INTERFACE,
        ],
      ],
    ] + $this->viewElement($address, 'en');

    return render($element);
  }