Skip to content

Commit

Permalink
Enforce consistency
Browse files Browse the repository at this point in the history
  • Loading branch information
Omranic committed Nov 26, 2016
1 parent 340680e commit 4e84496
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 10 deletions.
10 changes: 5 additions & 5 deletions src/Country.php
Expand Up @@ -95,7 +95,7 @@ public function getOfficialName()
/**
* Get the given native name or fallback to first native name.
*
* @param string $language
* @param string|null $language
*
* @return string|null
*/
Expand All @@ -112,7 +112,7 @@ public function getNativeName($language = null)
/**
* Get the given native official name or fallback to first native official name.
*
* @param string $language
* @param string|null $language
*
* @return string|null
*/
Expand Down Expand Up @@ -189,7 +189,7 @@ public function getIsoNumeric()
/**
* Get the given currency or fallback to first currency.
*
* @param string $currency
* @param string|null $currency
*
* @return string|null
*/
Expand Down Expand Up @@ -243,7 +243,7 @@ public function getAltSpellings()
/**
* Get the given language or fallback to first language.
*
* @param string $language
* @param string|null $language
*
* @return string|null
*/
Expand All @@ -267,7 +267,7 @@ public function getLanguages()
/**
* Get the translation.
*
* @param string $language
* @param string|null $language
*
* @return array
*/
Expand Down
11 changes: 6 additions & 5 deletions src/Loader.php
Expand Up @@ -69,27 +69,28 @@ public static function countries($longlist = false, $hydrate = false)
* @param mixed $value
* @param bool $strict
*
* @return static
* @return array
*/
public static function where($key, $value, $strict = true)
{
if (! isset(self::$countries['longlist'])) {
self::$countries['longlist'] = json_decode(self::getFile(__DIR__.'/../resources/data/longlist.json'), true);
}

return self::filter(function ($item) use ($key, $value, $strict) {
return self::filter(self::$countries['longlist'], function ($item) use ($key, $value, $strict) {
return $strict ? self::get($item, $key) === $value : self::get($item, $key) == $value;
}, self::$countries['longlist']);
});
}

/**
* Run a filter over each of the items.
*
* @param array $items
* @param callable|null $callback
*
* @return mixed
* @return array
*/
public static function filter(callable $callback = null, $items)
public static function filter($items, callable $callback = null)
{
if ($callback) {
$return = [];
Expand Down

0 comments on commit 4e84496

Please sign in to comment.