Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added continents #43

Open
wants to merge 8 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 10 additions & 9 deletions src/Webpatser/Countries/Countries.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ protected function getCountries()

/**
* Returns one country
*
*
* @param string $id The country id
*
* @return array
Expand All @@ -63,19 +63,19 @@ public function getOne($id)

/**
* Returns a list of countries
*
*
* @param string sort
*
*
* @return array
*/
public function getList($sort = null)
{
//Get the countries list
$countries = $this->getCountries();

//Sorting
$validSorts = array(
'capital',
'capital',
'citizenship',
'country-code',
'currency',
Expand All @@ -90,9 +90,10 @@ public function getList($sort = null)
'eea',
'calling_code',
'currency_symbol',
'flag'
'flag',
'continent'
);

if (!is_null($sort) && in_array($sort, $validSorts)){
uasort($countries, function($a, $b) use ($sort) {
if (!isset($a[$sort]) && !isset($b[$sort])){
Expand All @@ -103,10 +104,10 @@ public function getList($sort = null)
return 1;
} else {
return strcasecmp($a[$sort], $b[$sort]);
}
}
});
}

//Return the countries
return $countries;
}
Expand Down
Loading