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

HasTimezone   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 34
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 13
dl 0
loc 34
rs 10
c 1
b 0
f 0
wmc 6

4 Methods

Rating   Name   Duplication   Size   Complexity  
A setDetectTimezone() 0 5 1
A getDetectTimezone() 0 8 2
A setTimezone() 0 5 1
A getTimezone() 0 8 2
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