OpeningHours   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 59
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
wmc 5
eloc 14
c 1
b 0
f 1
dl 0
loc 59
rs 10

5 Methods

Rating   Name   Duplication   Size   Complexity  
A isOpenNow() 0 3 1
A getWeekdayText() 0 3 1
A getPeriods() 0 3 1
A __construct() 0 5 1
A fromResult() 0 6 1
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