Total Complexity | 3 |
Total Lines | 32 |
Duplicated Lines | 0 % |
Coverage | 100% |
Changes | 3 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
8 | class Timezone |
||
9 | { |
||
10 | /** |
||
11 | * Return collection of city with its timezone value. |
||
12 | * |
||
13 | * @return \Illuminate\Support\LazyCollection |
||
14 | */ |
||
15 | 2 | public static function collection(): LazyCollection |
|
16 | { |
||
17 | 2 | return LazyCollection::make(function () { |
|
18 | 2 | $handle = fopen(__DIR__ . '/../../storage/timezone.ndjson', 'r'); |
|
19 | |||
20 | 2 | while (($line = fgets($handle)) !== false) { |
|
21 | 2 | yield json_decode($line, true); |
|
22 | } |
||
23 | 2 | }); |
|
24 | } |
||
25 | |||
26 | /** |
||
27 | * Return timezone value based on given city name. |
||
28 | * |
||
29 | * @param string $city |
||
30 | * @param string|null $default |
||
31 | * @return string|null |
||
32 | */ |
||
33 | 2 | public static function getTimezone(string $city, string $default = null): ?string |
|
40 | } |
||
41 | } |
||
42 |