Conditions | 3 |
Paths | 4 |
Total Lines | 26 |
Lines | 0 |
Ratio | 0 % |
Tests | 18 |
CRAP Score | 3 |
Changes | 0 |
1 | <?php |
||
24 | 3 | public static function generate($id) |
|
25 | { |
||
26 | 3 | static $inst = null; |
|
27 | 3 | if($inst === null) |
|
28 | 3 | { |
|
29 | 1 | $inst = new CountryFactory(); |
|
30 | 1 | $inst->countries = require('countries.php'); |
|
31 | 1 | } |
|
32 | |||
33 | 3 | if(!isset($inst->countries[$id])) { |
|
34 | 1 | throw new InvalidArgumentException('No country found with that ID'); |
|
35 | } |
||
36 | |||
37 | 2 | $c = $inst->countries[$id]; |
|
38 | |||
39 | |||
40 | 2 | $country = new Country(); |
|
41 | 2 | $country->setId($c['id']) |
|
42 | 2 | ->setIso($c['iso']) |
|
43 | 2 | ->setName($c['name']) |
|
44 | 2 | ->setCountry($c['country']) |
|
45 | 2 | ->setNumCode($c['numcode']) |
|
46 | 2 | ->setFlag($c['flag']); |
|
47 | |||
48 | 2 | return $country; |
|
49 | } |
||
50 | } |