Passed
Push — master ( 463105...84cd59 )
by Roberto
04:47
created

TimeZoneByUF   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 48
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 2
c 0
b 0
f 0
lcom 1
cbo 1
dl 0
loc 48
ccs 6
cts 6
cp 1
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A get() 0 10 2
1
<?php
2
3
namespace NFePHP\Common;
4
5
/**
6
 * Returns Time Zone Strings for use of DateTime classes
7
 * @category   NFePHP
8
 * @package    NFePHP\Common
9
 * @copyright  Copyright (c) 2008-2017
10
 * @license    http://www.gnu.org/licenses/lesser.html LGPL v3
11
 * @license    https://opensource.org/licenses/MIT MIT
12
 * @license    http://www.gnu.org/licenses/gpl.txt GPLv3+
13
 * @author     Roberto L. Machado <linux.rlm at gmail dot com>
14
 * @link       http://github.com/nfephp-org/sped-common for the canonical source repository
15
 */
16
17
use NFePHP\Common\UFList;
18
19
class TimeZoneByUF
20
{
21
    protected static $tzd = [
22
        'AC'=>'America/Rio_Branco',
23
        'AL'=>'America/Maceio',
24
        'AM'=>'America/Manaus',
25
        'AP'=>'America/Belem',
26
        'BA'=>'America/Bahia',
27
        'CE'=>'America/Fortaleza',
28
        'DF'=>'America/Sao_Paulo',
29
        'ES'=>'America/Sao_Paulo',
30
        'GO'=>'America/Sao_Paulo',
31
        'MA'=>'America/Fortaleza',
32
        'MG'=>'America/Sao_Paulo',
33
        'MS'=>'America/Campo_Grande',
34
        'MT'=>'America/Cuiaba',
35
        'PA'=>'America/Belem',
36
        'PB'=>'America/Fortaleza',
37
        'PE'=>'America/Recife',
38
        'PI'=>'America/Fortaleza',
39
        'PR'=>'America/Sao_Paulo',
40
        'RJ'=>'America/Sao_Paulo',
41
        'RN'=>'America/Fortaleza',
42
        'RO'=>'America/Porto_Velho',
43
        'RR'=>'America/Boa_Vista',
44
        'RS'=>'America/Sao_Paulo',
45
        'SC'=>'America/Sao_Paulo',
46
        'SE'=>'America/Maceio',
47
        'SP'=>'America/Sao_Paulo',
48
        'TO'=>'America/Araguaina'
49
    ];
50
   
51
    /**
52
     * Return timezone string
53
     * @param string $uf
54
     * @return string
55
     */
56 2
    public static function get($uf)
57
    {
58 2
        $uf = strtoupper($uf);
59 2
        if (is_numeric($uf)) {
60 1
            $uf = UFList::getUFByCode($uf);
61
        }
62
        //only for validation, if $uf dont exists throws exception
63 2
        $code = UFList::getCodeByUF($uf);
0 ignored issues
show
Unused Code introduced by
$code is not used, you could remove the assignment.

This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.

$myVar = 'Value';
$higher = false;

if (rand(1, 6) > 3) {
    $higher = true;
} else {
    $higher = false;
}

Both the $myVar assignment in line 1 and the $higher assignment in line 2 are dead. The first because $myVar is never used and the second because $higher is always overwritten for every possible time line.

Loading history...
64 2
        return self::$tzd[$uf];
65
    }
66
}
67