Skip to content

Commit

Permalink
update abbreviation function
Browse files Browse the repository at this point in the history
  • Loading branch information
alisissa committed Dec 15, 2016
1 parent af23d71 commit a19d2be
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 6 deletions.
13 changes: 9 additions & 4 deletions src/Vinelab/Country/Guide.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,19 @@ public function name($abbreviation)
public function abbreviation($name)
{
$countries = $this->config->get('countries');

return array_search(ucwords($name), $countries);
if (array_search(ucwords($name), $countries)) {
return array_search(ucwords($name), $countries);
} else {
foreach ($countries as $key => $value) {
if (is_array($value) && in_array(strtolower($name), array_map('strtolower', $value))) {
return $key;
}
}
}
}

public function all()
{
return $this->config->get('countries');
}

}

4 changes: 2 additions & 2 deletions src/config/countries.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

return array(
'AD' => 'Andorra',
'AE' => 'United Arab Emirates',
'AE' => ['UAE', 'United Arab Emirates'],
'AF' => 'Afghanistan',
'AG' => 'Antigua and Barbuda',
'AI' => 'Anguilla',
Expand Down Expand Up @@ -64,7 +64,7 @@
'DJ' => 'Djibouti',
'DK' => 'Denmark',
'DM' => 'Dominica',
'DO' => 'Dominican Republic',
'DO' => ['Dominican Republic', 'Dom. Republic'],
'DZ' => 'Algeria',
'EC' => 'Ecuador',
'EE' => 'Estonia',
Expand Down

0 comments on commit a19d2be

Please sign in to comment.