|
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); |
|
|
|
|
|
|
64
|
2 |
|
return self::$tzd[$uf]; |
|
65
|
|
|
} |
|
66
|
|
|
} |
|
67
|
|
|
|
This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.
Both the
$myVarassignment in line 1 and the$higherassignment in line 2 are dead. The first because$myVaris never used and the second because$higheris always overwritten for every possible time line.