1 | <?php |
||
7 | class EveryPolitician |
||
8 | { |
||
9 | private $url; |
||
10 | private $filename; |
||
11 | private $countriesJsonData; |
||
12 | |||
13 | const TYPE_FILENAME = 0; |
||
14 | const TYPE_URL = 1; |
||
15 | const DEFAULT_COUNTRIES_JSON_URL = 'https://raw.githubusercontent.com/' |
||
16 | .'everypolitician/everypolitician-data/master/countries.json'; |
||
17 | |||
18 | /** |
||
19 | * Creates a new instance |
||
20 | * |
||
21 | * @param string $urlOrFilename URL or filename of Popolo json |
||
22 | * @param int $type the delimiters to consider |
||
23 | */ |
||
24 | 60 | public function __construct($urlOrFilename = self::DEFAULT_COUNTRIES_JSON_URL, $type = self::TYPE_URL) |
|
37 | |||
38 | /** |
||
39 | * String representation of {@link EveryPolitician} |
||
40 | * |
||
41 | * @return string |
||
42 | */ |
||
43 | 9 | public function __toString() |
|
48 | |||
49 | /** |
||
50 | * Return a new {@link EveryPolitician} from a filename |
||
51 | * of a Popolo json file |
||
52 | * |
||
53 | * @param string $filename filename of a Popolo json file |
||
54 | * |
||
55 | * @return static |
||
56 | */ |
||
57 | 6 | public static function fromFilename($filename) |
|
61 | |||
62 | /** |
||
63 | * Return a new {@link EveryPolitician} from a URL |
||
64 | * pointing to a Popolo json file |
||
65 | * |
||
66 | * @param string $url URL pointing to a Popolo json file |
||
67 | * |
||
68 | * @return static |
||
69 | */ |
||
70 | 3 | public static function fromUrl($url) |
|
74 | |||
75 | 51 | private function countriesJsonData() |
|
90 | |||
91 | /** |
||
92 | * Return a list of all known {@link Country}s |
||
93 | * |
||
94 | * @return Country[] |
||
95 | */ |
||
96 | 51 | public function countries() |
|
105 | |||
106 | /** |
||
107 | * Return a {@link Country} object from a country slug |
||
108 | * |
||
109 | * @param string $countrySlug slug identifying a country |
||
110 | * |
||
111 | * @return Country |
||
112 | */ |
||
113 | 42 | public function country($countrySlug) |
|
122 | |||
123 | /** |
||
124 | * Return an array containing a {@link Country} and a |
||
125 | * {@link Legislature} object from their slugs |
||
126 | * |
||
127 | * @param string $countrySlug slug identifying a country |
||
128 | * @param string $legislatureSlug slug identifying a legislature |
||
129 | * |
||
130 | * @return array |
||
131 | */ |
||
132 | 12 | public function countryLegislature($countrySlug, $legislatureSlug) |
|
138 | } |
||
139 |