TimeZoneHelper   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 20
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Importance

Changes 2
Bugs 0 Features 1
Metric Value
wmc 2
c 2
b 0
f 1
lcom 0
cbo 0
dl 0
loc 20
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A listTimeZone() 0 12 2
1
<?php
2
/**
3
 * @link http://www.writesdown.com/
4
 * @copyright Copyright (c) 2015 WritesDown
5
 * @license http://www.writesdown.com/license/
6
 */
7
8
namespace common\components;
9
10
/**
11
 * List of timezones with GMT offset.
12
 *
13
 * @author Agiel K. Saputra <[email protected]>
14
 * @since 0.1.0
15
 */
16
class TimeZoneHelper
17
{
18
    /**
19
     * List of timezone as array.
20
     *
21
     * @return array
22
     */
23
    public static function listTimeZone()
24
    {
25
        $timezone = [];
26
        $timestamp = time();
27
28
        foreach (timezone_identifiers_list() as $zone) {
29
            date_default_timezone_set($zone);
30
            $timezone[$zone] = $zone . ' UTC/GMT ' . date('P', $timestamp);
31
        }
32
33
        return $timezone;
34
    }
35
}
36