Completed
Push — master ( 18c02e...701e2d )
by Sébastien
05:57
created

System::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 5
ccs 4
cts 4
cp 1
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 3
nc 1
nop 1
crap 1
1
<?php
2
3
declare(strict_types=1);
4
5
/*
6
 * Soluble Japha
7
 *
8
 * @link      https://github.com/belgattitude/soluble-japha
9
 * @copyright Copyright (c) 2013-2017 Vanvelthem Sébastien
10
 * @license   MIT License https://github.com/belgattitude/soluble-japha/blob/master/LICENSE.md
11
 */
12
13
namespace Soluble\Japha\Bridge\Adapter;
14
15
use Soluble\Japha\Bridge;
16
use Soluble\Japha\Interfaces;
17
use Soluble\Japha\Util\TimeZone;
18
use Soluble\Japha\Util\Exception\UnsupportedTzException;
19
20
class System
21
{
22
    /**
23
     * @var Bridge\Adapter
24
     */
25
    protected $ba;
26
27
    /**
28
     * @var TimeZone
29
     */
30
    protected $timeZone;
31
32
    /**
33
     * @param Bridge\Adapter $ba
34
     */
35 8
    public function __construct(Bridge\Adapter $ba)
36
    {
37 8
        $this->ba = $ba;
38 8
        $this->timeZone = new TimeZone($ba);
39 8
    }
40
41
    /**
42
     * Get php DateTime helper object.
43
     *
44
     * @return TimeZone
45
     */
46 1
    public function getTimeZone(): TimeZone
47
    {
48 1
        return $this->timeZone;
49
    }
50
51
    /**
52
     * Return system default timezone id.
53
     *
54
     * @return string
55
     */
56 3
    public function getTimeZoneId(): string
57
    {
58 3
        return (string) $this->timeZone->getDefault()->getID();
59
    }
60
61
    /**
62
     * Set system default timezone.
63
     *
64
     * @throws UnsupportedTzException
65
     *
66
     * @param string|Interfaces\JavaObject|\DateTimeZone $timezone timezone id, Java(java.util.Timezone) or php DateTimeZone
67
     */
68 5
    public function setTimeZoneId($timezone): void
69
    {
70 5
        $this->timeZone->setDefault($timezone);
71 2
    }
72
}
73