Passed
Pull Request — master (#68)
by Sergey
07:18
created

HasTimezone::setTimezone()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 2
nc 1
nop 1
dl 0
loc 5
rs 10
c 1
b 0
f 0
1
<?php
2
3
namespace JamesMills\LaravelTimezone\Traits;
4
5
trait HasTimezone
6
{
7
    public function getTimezone(): ?string
8
    {
9
        $timezone = $this->timezone;
10
        if ($timezone === null) {
11
            return null;
12
        }
13
14
        return (string) $timezone;
15
    }
16
17
    public function getDetectTimezone(): ?bool
18
    {
19
        $detectTimezone = $this->detect_timezone;
20
        if ($detectTimezone === null) {
21
            return null;
22
        }
23
24
        return (bool) $detectTimezone;
25
    }
26
27
    public function setTimezone(?string $timezone)
28
    {
29
        $this->timezone = $timezone;
0 ignored issues
show
Bug Best Practice introduced by
The property timezone does not exist. Although not strictly required by PHP, it is generally a best practice to declare properties explicitly.
Loading history...
30
31
        return $this;
32
    }
33
34
    public function setDetectTimezone(?bool $detectTimezone)
35
    {
36
        $this->detect_timezone = $detectTimezone;
0 ignored issues
show
Bug Best Practice introduced by
The property detect_timezone does not exist. Although not strictly required by PHP, it is generally a best practice to declare properties explicitly.
Loading history...
37
38
        return $this;
39
    }
40
}
41