Skip to content

Commit

Permalink
Rename country variable to countryCode for naming consistency
Browse files Browse the repository at this point in the history
  • Loading branch information
Omranic committed Apr 7, 2017
1 parent 247dccb commit 2e260d8
Showing 1 changed file with 15 additions and 15 deletions.
30 changes: 15 additions & 15 deletions src/Country.php
Original file line number Diff line number Diff line change
Expand Up @@ -141,30 +141,30 @@ public function getOfficialName()
/**
* Get the given native name or fallback to first native name.
*
* @param string|null $language
* @param string|null $languageCode
*
* @return string|null
*/
public function getNativeName($language = null)
public function getNativeName($languageCode = null)
{
$language = $language ? mb_strtolower($language) : null;
$languageCode = $languageCode ? mb_strtolower($languageCode) : null;

return $this->get("name.native.{$language}.common")
return $this->get("name.native.{$languageCode}.common")
?: (current($this->get('name.native', []))['common'] ?: $this->get('native_name'));
}

/**
* Get the given native official name or fallback to first native official name.
*
* @param string|null $language
* @param string|null $languageCode
*
* @return string|null
*/
public function getNativeOfficialName($language = null)
public function getNativeOfficialName($languageCode = null)
{
$language = $language ? mb_strtolower($language) : null;
$languageCode = $languageCode ? mb_strtolower($languageCode) : null;

return $this->get("name.native.{$language}.official")
return $this->get("name.native.{$languageCode}.official")
?: (current($this->get('name.native', []))['official'] ?: $this->get('native_official_name'));
}

Expand Down Expand Up @@ -285,15 +285,15 @@ public function getAltSpellings()
/**
* Get the given language or fallback to first language.
*
* @param string|null $language
* @param string|null $languageCode
*
* @return string|null
*/
public function getLanguage($language = null)
public function getLanguage($languageCode = null)
{
$language = $language ? mb_strtoupper($language) : null;
$languageCode = $languageCode ? mb_strtoupper($languageCode) : null;

return $this->get("languages.{$language}") ?: (current($this->get('languages', [])) ?: null);
return $this->get("languages.{$languageCode}") ?: (current($this->get('languages', [])) ?: null);
}

/**
Expand Down Expand Up @@ -340,13 +340,13 @@ public function getTranslations()
/**
* Get the translation.
*
* @param string|null $language
* @param string|null $languageCode
*
* @return array
*/
public function getTranslation($language = null)
public function getTranslation($languageCode = null)
{
return $this->getTranslations()[$language] ?? current($this->getTranslations());
return $this->getTranslations()[$languageCode] ?? current($this->getTranslations());
}

/**
Expand Down

0 comments on commit 2e260d8

Please sign in to comment.