Completed
Pull Request — master (#2)
by Andreas
02:06
created

Location::getLatitude()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 0
dl 0
loc 3
rs 10
c 0
b 0
f 0
1
<?php
2
3
/*
4
 * Copyright (c) DateTime-Contributors
5
 *
6
 * Licensed under the MIT License. See LICENSE.md file in the project root
7
 * for full license information.
8
 */
9
10
namespace DateTime\Timezone;
11
12
use Closure;
13
14
class Location
15
{
16
    private $countryCode;
17
18
    private $latitude;
19
20
    private $longitude;
21
22
    private $comment;
23
24
    private function __construct(string $countryCode, float $latitude, float $longitude, string $comment)
25
    {
26
        $this->countryCode = $countryCode;
27
        $this->latitude = $latitude;
28
        $this->longitude = $longitude;
29
        $this->comment = $comment;
30
    }
31
32
    public static function fromTimezone(Name $timezone) : self
33
    {
34
        $timezoneThief = function (Name $timezone) {
35
            return $timezone->timezone;
0 ignored issues
show
Bug introduced by
The property timezone is declared protected in DateTime\Timezone\Timezone and cannot be accessed from this context.
Loading history...
36
        };
37
        $timezoneThief = Closure::bind($timezoneThief, null, $timezone);
38
        $location = $timezoneThief($timezone)->getLocation();
39
        return new self(
40
            $location['country_code'],
41
            $location['latitude'],
42
            $location['longitude'],
43
            $location['comments']
44
        );
45
    }
46
47
    public function getCountryCode() : string
48
    {
49
        return $this->countryCode;
50
    }
51
52
    public function getLatitude() : float
53
    {
54
        return $this->latitude;
55
    }
56
57
    public function getLongitude() : float
58
    {
59
        return $this->longitude;
60
    }
61
62
    public function getComments() : string
63
    {
64
        return $this->comment;
65
    }
66
}
67