Return ISO-Code for Magento address

@param DataObject $address

@return null|string
178553
public function getIsoStateByMagentoRegion(DataObject $address)
    {
        $map      = $this->getIsoToMagentoMapping();
        $sIsoCode = null;

        if ($address->getData('country_id') && $address->getData('region_code')) {
            $sIsoCode = $address->getData('country_id') . "-" . $address->getData('region_code');
        }

        if (isset($map[$address->getData('country_id')])) {
            foreach ($map[$address->getData('country_id')] as $isoCode => $mageCode) {
                if ($mageCode === $address->getData('region_code')) {
                    $sIsoCode = $address->getData('country_id') . "-" . $isoCode;
                    break;
                }
            }
        }

        return $sIsoCode;
    }
445727
protected function formatAddress($address, $port)
    {
        if ($port !== 0) {
            if (strpos($address, ':') !== false) {
                $address = '[' . $address . ']';
            }
            $address .= ':' . $port;
        }
        return $address;
    }
481533
public static function geocode($address)
	{
		if(!is_string($address)) return array();
		
		$query = new Dm_Geocoder_Query($address);
		$finded = Dm_Geocoder_GISCSV_Finder::find($query);
		
		return $finded;
		
	}
1063688
public function getBalanceByAddress($address)
    {
        $args = [
            (string)$address,
            $this->minconf
        ];
        return $this->rpc->query("getReceivedByAddress", $args);
    }
964517
protected function getIso2Code(DataSetInterface $dataSet)
    {
        if (isset($dataSet[CompanyUnitAddressDataSet::COUNTRY_ISO_2_CODE]) && !empty($dataSet[CompanyUnitAddressDataSet::COUNTRY_ISO_2_CODE])) {
            return $dataSet[CompanyUnitAddressDataSet::COUNTRY_ISO_2_CODE];
        }

        return null;
    }
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;
    }
1347158
public function findAllCartsWithAddress(AddressInterface $address)
    {
        $queryBuilder = $this
            ->createQueryBuilder('c');

        $result = $queryBuilder
            ->innerJoin('c.billingAddress', 'b')
            ->innerJoin('c.deliveryAddress', 'd')
            ->where(
                $queryBuilder->expr()->orX(
                    $queryBuilder->expr()->eq('b.id', ':customerId'),
                    $queryBuilder->expr()->eq('c.id', ':addressId')
                )
            )
            ->setParameter('customerId', $address->getId())
            ->setParameter('addressId', $address->getId())
            ->getQuery()
            ->getResult();

        return $result;
    }
1312000
public function getPrivateKeyByAddress($address)
    {
        $args = [
            (string)$address
        ];

        $priv_key = null;
        try {
            $priv_key = $this->rpc->query("dumpPrivKey", $args);
        } catch (Exceptions\RPCException $e) {
            if ($e->getCode() != RPCErrorCodes::WALLET_ERROR) {
                throw $e;
            }
        }

        return $priv_key;
    }
154079
public function convertAddressFromAmazonObjectToLocal(OffAmazonPaymentsService_Model_Address $address, $targetAddressType)
    {
        return $this->convertAddressFromAmazonToLocal(
            array(
                'Name' => $address->getName(),
                'AddressLine1' => $address->getAddressLine1(),
                'AddressLine2' => $address->getAddressLine2(),
                'AddressLine3' => $address->getAddressLine3(),
                'County' => $address->getCounty(),
                'District' => $address->getDistrict(),
                'StateOrRegion' => $address->getStateOrRegion(),
                'City' => $address->getCity(),
                'PostalCode' => $address->getPostalCode(),
                'Phone' => $address->getPhone(),
                'CountryCode' => $address->getCountryCode(),
            ),
            $targetAddressType
        );
    }
367483
public function getReplacementsFor($address)
    {
        $organism = $this->manager->getRepository('LibrinfoCRMBundle:Organism')->findOneBy(array('email' => $address));

        if ($organism) {
            if ($organism->isIndividual()) {
                return array(
                    '{prenom}' => $organism->getFirstName(),
                    '{nom}'    => $organism->getLastName(),
                    '{titre}'  => $organism->getTitle(),
                );
            } else {
                return array(
                    '{nom}' => $organism->getName(),
                );
            }
        }
    }
1170524
protected function parse($address)
	{
		
		//全角数字を半角に。全角スペースを半角に。
		$address = mb_convert_kana($address,'ns');
		
		//半角スペースを削除
		$address = str_replace(' ','',$address);
		
		//県を特定し、検索文字列から県を除外
		foreach (Dm_Geocoder_Prefecture::get() as $code => $name) {
			$splited = preg_split('/'.$name.'/',$address);
			if(count($splited)<=1) continue;
			$this->prefectureCode = $code;
			$this->prefectureName = $name;
			$address = $name.$splited[1];
			break;
		}
		
		//住所中の数値を漢数字に変換する
		$address = preg_replace_callback('/[0-9]+/msu',
		//$address = preg_replace_callback('/[0-9.\.-]+/msu',
		create_function('$mt', 'return Dm_Geocoder_Query::num2kan_decimal($mt[0]);'), $address);
		
		//都道府県名以降の住所
		$this->address = $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;
    }
1097766
protected function getFromCache($address, $country)
    {
        $builder = $this->connection->createQueryBuilder();
        $builder
            ->select('*')
            ->from($this->connection->quoteIdentifier('tl_metamodel_perimetersearch'))
            ->where($builder->expr()->eq($this->connection->quoteIdentifier('search'), ':search'))
            ->andWhere($builder->expr()->eq($this->connection->quoteIdentifier('country'), ':country'))
            ->setParameter('search', $address)
            ->setParameter('country', $country);

        $statement = $builder->execute();

        // If we have no data just return null.
        if (!$statement->rowCount()) {
            return null;
        }

        $result = $statement->fetch(\PDO::FETCH_OBJ);

        // Build a new container.
        $container = new Container();
        $container->setLatitude($result->geo_lat);
        $container->setLongitude($result->geo_long);
        $container->setSearchParam(
            \strtr(
                $builder->getSQL(),
                [
                    ':search'  => $this->connection->quote($address),
                    ':country' => $this->connection->quote($country)
                ]
            )
        );

        return $container;
    }
1271302
public function geocode($address)
    {
        $query = $this->buildQuery('address', $address);

        $response = $this->validateResponse(
            $this->getResponse($query)
        );

        return $this->buildResults($response['results']);
    }
1183187
public function getCoordinatesByString(string $address) : CoordinatesInterface
    {
        $url = $this->addressQuery($address);
        $json = $this->fetchUrl($url);

        // convert google data to coordinates
        $coordinates = CoordinatesBuild::create($json->results[0]);

        return $coordinates;
    }
1137326
final public function getFrom(): ?EmailAddress
    {
        $from = $this->getHeaders()->get('from');

        return null !== $from ? $this->decodeEmailAddress($from[0]) : null;
    }
791547
public function convertAddressFromAmazonToLocal(array $address, $targetAddressType)
    {
        $mapping = array(
            'Name' => 'lastname',
            'AddressLine1' => 'company',
            'AddressLine2' => 'street',
            'AddressLine3' => 'address_additional_info',
            'County' => null,
            'District' => null,
            'StateOrRegion' => null,
            'City' => 'city',
            'PostalCode' => 'postalcode',
            'Phone' => 'telefon',
            'CountryCode' => 'data_country_id',
        );

        foreach (array_keys($address) as $field) {
            if (false === array_key_exists($field, $mapping)) {
                throw new InvalidArgumentException(
                    'invalid field '.$field.' (valid fields are: "'.implode(
                        '", "',
                        array_keys($mapping)
                    ).'")'
                );
            }
        }

        $target = array();
        foreach ($address as $field => $value) {
            if (null === $mapping[$field]) {
                continue;
            }
            if ('CountryCode' !== $field) {
                $target[$mapping[$field]] = $value;
            } else {
                $target[$mapping[$field]] = $this->getCountryIdFromAmazonCountryCode($value, $targetAddressType);
            }
        }
        $target = $this->convertAddressLineData($target, $address);

        return $target;
    }