-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathexample.php
37 lines (30 loc) · 871 Bytes
/
example.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
<?php
use Uganda\Exceptions\DistrictNotFoundException;
use Uganda\Exceptions\ParishNotFoundException;
use Uganda\Uganda;
require 'vendor/autoload.php';
$uganda = new Uganda();
/**
* Fetch all Villages in Uganda
*/
$villages = $uganda->villages();
foreach ($villages as $village) {
echo $village->name() . "\n";
}
/**
* Fetch all Sub Counties in a District
*/
try {
$subCountiesInDistrict = $uganda->district('Bukomansimbi')->subCounties();
} catch (DistrictNotFoundException $e) {
// Calling for a Specific Location can throw an Exception if it doesn't exist
}
/**
* Getting all the Parish information as an array
*/
try {
$parishInformation = $uganda->parish('Akwangagwel')->toArray();
print_r($parishInformation);
} catch (ParishNotFoundException $e) {
// Calling for a Specific Location can throw an Exception if it doesn't exist
}