| Conditions | 3 |
| Paths | 3 |
| Total Lines | 19 |
| Code Lines | 12 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 13 |
| CRAP Score | 3 |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 15 | 1 | public function getAll(): array |
|
| 16 | { |
||
| 17 | 1 | $timeZones = []; |
|
| 18 | 1 | $timeZoneIdentifiers = \DateTimeZone::listIdentifiers(); |
|
| 19 | |||
| 20 | 1 | foreach ($timeZoneIdentifiers as $timeZone) { |
|
| 21 | 1 | $date = new \DateTime('now', new \DateTimeZone($timeZone)); |
|
| 22 | 1 | $offset = $date->getOffset(); |
|
| 23 | 1 | $tz = ($offset > 0 ? '+' : '-') . gmdate('H:i', (int) abs($offset)); |
|
| 24 | 1 | $timeZones[] = [ |
|
| 25 | 1 | 'timezone' => $timeZone, |
|
| 26 | 1 | 'name' => "{$timeZone} (UTC {$tz})", |
|
| 27 | 1 | 'offset' => $offset |
|
| 28 | ]; |
||
| 29 | } |
||
| 30 | |||
| 31 | 1 | \yii\helpers\ArrayHelper::multisort($timeZones, 'offset', SORT_DESC, SORT_NUMERIC); |
|
| 32 | |||
| 33 | 1 | return $timeZones; |
|
| 34 | } |
||
| 36 |