@param array $siteData

@return Country|null
197080
protected function buildCountry(array $siteData)
    {
        if (!empty($siteData['country']) && $siteData['country'] instanceof Country) {
            return $siteData['country'];
        }

        if (!empty($siteData['countryId'])) {
            $country = $this->countryRepository->findOneBy(
                ['iso3' => $siteData['countryId']]
            );

            if (empty($country)) {
                throw new CountryNotFoundException("Country {$siteData['countryId']} could not be found.");
            }

            return $country;
        }

        if (!empty($siteData['countryIso3'])) {
            $country = $this->countryRepository->findOneBy(
                ['iso3' => $siteData['countryIso3']]
            );
            if (empty($country)) {
                throw new CountryNotFoundException("Country {$siteData['countryIso3']} could not be found.");
            }

            return $country;
        }

        return null;
    }
1251080
public function getCountry()
    {
        if (! $this->country) {
            $this->country = $this->filterValidCountry($this->countries);
        }

        return $this->country;
    }
981519
public function country($country_id, Request $request = null)
    {
        $country = Country::with('zone')->find($country_id);

        if ($request) {
            $included = [];
            $query = $country->getInlcudeResources($request->include);
            if ($query) {
                $collection = new Collection(
                    $query,
                    str_singular($request->include)
                );
                $included = $collection->toArray();
            }
            $links = $request ? ['self' => $request->url()] : [];
            return $this->respondWithItem(
                $country,
                'country',
                $links,
                $included
            );
        }
        return $country;
    }
624377
public function getCountryIdAttribute()
    {
        if (isset($this->attributes['country_id']) && $this->attributes['country_id'] > 0) {
            return $this->attributes['country_id'];
        }

        $configRepository = app(ConfigurationInterface::class);
        $defaultCountry = $configRepository->getValueByKey('user_default_country');

        if (isset($defaultCountry)) {
            return $defaultCountry;
        }

        return null;
    }
1122220
public function countries(Request $request = null)
    {
        $query = Country::with('zone');

        if ($request) {
            $resource = new Collection($query, 'country', $request);
            return $this->respondWithCollection($resource);
        }
        return $query->get();
    }
1349408
protected function _geocode($entity, array $addressData) {
		$entityData = [
			'geocoder_result' => [],
		];

		$search = implode(' ', $addressData);
		if ($search === '') {
			if (!$this->_config['allowEmpty']) {
				return null;
			}

			return $entity;
		}

		$address = $this->_execute($search);
		if (!$address) {
			if ($this->_config['allowEmpty']) {
				return $entity;
			}
			if ($entity instanceof Entity) {
				$this->invalidate($entity);
			}
			return null;
		}

		if (!$this->_Geocoder->isExpectedType($address)) {
			if ($this->_config['allowEmpty']) {
				return $entity;
			}
			if ($entity instanceof Entity) {
				$this->invalidate($entity);
			}
			return null;
		}

		// Valid lat/lng found
		$entityData[$this->_config['lat']] = $address->getLatitude();
		$entityData[$this->_config['lng']] = $address->getLongitude();

		if (!empty($this->_config['formatted_address'])) {
			// Unfortunately, the formatted address of google is lost
			$formatter = new StringFormatter();
			$entityData[$this->_config['formatted_address']] = $formatter->format($address, '%S %n, %z %L');
		}

		$entityData['geocoder_result'] = $address->toArray();
		$entityData['geocoder_result']['address_data'] = implode(' ', $addressData);

		if (!empty($this->_config['update'])) {
			foreach ($this->_config['update'] as $key => $field) {
				//FIXME, not so easy with the new library
				if (!empty($geocode[$key])) {
					$entityData[$field] = $geocode[$key];
				}
			}
		}

		foreach ($entityData as $key => $value) {
			$entity[$key] = $value;
		}
		return $entity;
	}
288463
protected function getSite($siteId)
    {
        try {
            /** @var Site $site */
            $site = $this->getSiteRepo()->findOneBy(['siteId' => $siteId]);
        } catch (\Exception $e) {
            $site = null;
        }

        return $site;
    }
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;
    }
1258378
public function get($countryId, array $fields = array())
    {
        $params = array();
        if (!empty($fields)) {
            $params['fields'] = implode(',', $fields);
        }
        $endpoint = '/admin/countrys/'.$countryId.'.json';
        $response = $this->request($endpoint, 'GET', $params);
        return $this->createObject(Country::class, $response['country']);
    }
416421
public function col_country($data) {
        if ($data->country && $this->countries === null) {
            $this->countries = get_string_manager()->get_list_of_countries();
        }
        if (!empty($this->countries[$data->country])) {
            return $this->countries[$data->country];
        }
        return '';
    }
523281
public function selectCountry($country)
    {
        if (!isset($this->_issuerData)) {
            $this->_country = $this->validateCountry($country);
            return $this;
        }

        if (in_array($country, $this->getCountries())) {
            $this->_country = $this->validateCountry($country);
            return $this;
        };

        if (in_array("00", $this->getCountries())) {
            $this->_country = "00";
        };

        return $this;
    }
193358
public function setCurrentSite($siteId, $siteName, $siteDefaultLanguage, array $languages)
    {
        parent::setSite($siteId, $siteName, $siteDefaultLanguage, $languages);
    }
636383
public function country(array &$submitted, array $options = array())
    {
        $this->options = $options;
        $this->submitted = &$submitted;

        $this->validateCountry();
        $this->validateWeight();
        $this->validateBool('status');
        $this->validateCodeCountry();
        $this->validateName();
        $this->validateNativeNameCountry();
        $this->validateZoneCountry();
        $this->validateFormatCountry();

        $this->unsetSubmitted('update');

        return $this->getResult();
    }
1331325
public function getCountry($id)
    {
        foreach ($this->data as $country) {
            if (strtoupper($id) == (string) $country) {
                return $country;
            }
        }

        return null;
    }
167722
public function getCountryCode($country = null)
    {
        if ($country === null) {
            $country = $this->_country;
        }

        $code = KlarnaCountry::getCode($country);
        return (string) $code;
    }
654602
protected function validateCountryAddress()
    {
        $field = 'country';
        $value = $this->getSubmitted($field);

        if (!isset($value)) {
            $this->unsetSubmitted($field);
            return null;
        }

        $country = $this->country->get($value);
        $label = $this->translation->text('Country');

        if (empty($country)) {
            $this->setErrorUnavailable($field, $label);
            return false;
        }

        return true;
    }
1300748
public function getCountryLabel($strCountry)
    {
        $countries = $this->getCountries();

        return isset($countries[$strCountry]) ? $countries[$strCountry] : null;
    }