OpeningHours::getPeriods()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
eloc 1
c 1
b 0
f 1
dl 0
loc 3
rs 10
cc 1
nc 1
nop 0
1
<?php
2
3
declare(strict_types=1);
4
5
/*
6
 * This file is part of the Geocoder package.
7
 * For the full copyright and license information, please view the LICENSE
8
 * file that was distributed with this source code.
9
 *
10
 * @license    MIT License
11
 */
12
13
namespace Geocoder\Provider\GoogleMapsPlaces\Model;
14
15
use stdClass;
16
17
/**
18
 * @author atymic <[email protected]>
19
 */
20
class OpeningHours
21
{
22
    /**
23
     * @var bool|null
24
     */
25
    private $openNow;
26
27
    /**
28
     * @var array[]
29
     */
30
    private $periods;
31
32
    /**
33
     * @var string[]
34
     */
35
    private $weekdayText;
36
37
    /**
38
     * @param bool|null $openNow
39
     * @param array[]   $periods
40
     * @param string[]  $weekdayText
41
     */
42
    public function __construct($openNow, array $periods, array $weekdayText)
43
    {
44
        $this->openNow = $openNow;
45
        $this->periods = $periods;
46
        $this->weekdayText = $weekdayText;
47
    }
48
49
    /**
50
     * @return bool|null
51
     */
52
    public function isOpenNow()
53
    {
54
        return $this->openNow;
55
    }
56
57
    /**
58
     * @return array[]
59
     */
60
    public function getPeriods(): array
61
    {
62
        return $this->periods;
63
    }
64
65
    /**
66
     * @return string[]
67
     */
68
    public function getWeekdayText(): array
69
    {
70
        return $this->weekdayText;
71
    }
72
73
    public static function fromResult(stdClass $openingHours): self
74
    {
75
        return new self(
76
            $openingHours->open_now ?? null,
77
            $openingHours->periods ?? [],
78
            $openingHours->weekday_text ?? []
79
        );
80
    }
81
}
82