Passed
Push — master ( 120ad6...d2d121 )
by bader
07:57
created

Setters   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 64
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 12
dl 0
loc 64
rs 10
c 0
b 0
f 0
wmc 6

5 Methods

Rating   Name   Duplication   Size   Complexity  
A fresh() 0 5 1
A period() 0 7 2
A country() 0 5 1
A seconds() 0 5 1
A referer() 0 5 1
1
<?php
2
3
namespace awssat\Visits\Traits;
4
5
trait Setters
6
{
7
    /**
8
     * Return fresh cache from database
9
     * @return $this
10
     */
11
    public function fresh()
12
    {
13
        $this->fresh = true;
0 ignored issues
show
Bug Best Practice introduced by
The property fresh does not exist. Although not strictly required by PHP, it is generally a best practice to declare properties explicitly.
Loading history...
14
15
        return $this;
16
    }
17
18
    /**
19
     * set x seconds for ip expiration
20
     *
21
     * @param $seconds
22
     * @return $this
23
     */
24
    public function seconds($seconds)
25
    {
26
        $this->ipSeconds = $seconds;
0 ignored issues
show
Bug Best Practice introduced by
The property ipSeconds does not exist. Although not strictly required by PHP, it is generally a best practice to declare properties explicitly.
Loading history...
27
28
        return $this;
29
    }
30
31
32
    /**
33
     * @param $country
34
     * @return $this
35
     */
36
    public function country($country)
37
    {
38
        $this->country = $country;
0 ignored issues
show
Bug Best Practice introduced by
The property country does not exist. Although not strictly required by PHP, it is generally a best practice to declare properties explicitly.
Loading history...
39
40
        return $this;
41
    }
42
43
44
    /**
45
     * @param $referer
46
     * @return $this
47
     */
48
    public function referer($referer)
49
    {
50
        $this->referer = $referer;
0 ignored issues
show
Bug Best Practice introduced by
The property referer does not exist. Although not strictly required by PHP, it is generally a best practice to declare properties explicitly.
Loading history...
51
52
        return $this;
53
    }
54
55
56
    /**
57
     * Change period
58
     *
59
     * @param $period
60
     * @return $this
61
     */
62
    public function period($period)
63
    {
64
        if (in_array($period, array_keys($this->periods))) {
65
            $this->keys->visits = $this->keys->period($period);
66
        }
67
68
        return $this;
69
    }
70
}
71