File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -49,6 +49,18 @@ public function validateLocale(string $locale): void
4949 }
5050 }
5151
52+ public function getCountriesName (string $ locale = 'en ' ): array
53+ {
54+ $ this ->validateLocale ($ locale );
55+
56+ $ result = [];
57+ foreach ($ this ->countries as $ country ) {
58+ $ result [$ country ->alpha2 ] = $ country ->getName ($ locale );
59+ }
60+
61+ return $ result ;
62+ }
63+
5264 public function getCountriesAlpha2 (string $ locale = 'en ' ): array
5365 {
5466 $ this ->validateLocale ($ locale );
Original file line number Diff line number Diff line change 121121 expect ($ country )->toBeNull ();
122122});
123123
124+ it ('returns countries with names ' , function () {
125+ $ collection = new Collection ();
126+ $ countries = $ collection ->getCountriesName ();
127+
128+ expect ($ countries )->toBeArray ();
129+ expect ($ countries )->not ->toBeEmpty ();
130+ foreach ($ countries as $ alpha2 => $ name ) {
131+ expect ($ alpha2 )->toBeString ();
132+ expect ($ name )->toBeString ();
133+ }
134+ });
135+
124136it ('returns countries with alpha2 codes ' , function () {
125137 $ collection = new Collection ();
126138 $ countries = $ collection ->getCountriesAlpha2 ();
You can’t perform that action at this time.
0 commit comments