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

Record::recordRefer()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 2
nc 1
nop 1
dl 0
loc 4
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace awssat\Visits\Traits;
4
5
use Spatie\Referer\Referer;
6
7
trait Record
8
{
9
    /**
10
     * @param $inc
11
     */
12
    protected function recordCountry($inc)
13
    {
14
        $this->redis->zincrby($this->keys->visits . "_countries:{$this->keys->id}", $inc, $this->getVisitorCountry());
15
    }
16
17
    /**
18
     * @param $inc
19
     */
20
    protected function recordRefer($inc)
21
    {
22
        $referer = app(Referer::class)->get();
23
        $this->redis->zincrby($this->keys->visits . "_referers:{$this->keys->id}", $inc, $referer);
24
    }
25
26
    /**
27
     * @param $inc
28
     */
29
    protected function recordPeriods($inc)
30
    {
31
        foreach ($this->periods as $period) {
32
            $periodKey = $this->keys->period($period);
33
34
            $this->redis->zincrby($periodKey, $inc, $this->keys->id);
35
            $this->redis->incrby($periodKey . '_total', $inc);
36
        }
37
    }
38
39
    /**
40
     *  Gets visitor country code
41
     * @return mixed|string
42
     */
43
    protected function getVisitorCountry()
44
    {
45
        return strtolower(geoip()->getLocation()->iso_code);
0 ignored issues
show
Bug introduced by
The method getLocation() does not exist on Torann\GeoIP\Location. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

45
        return strtolower(geoip()->/** @scrutinizer ignore-call */ getLocation()->iso_code);

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
46
    }
47
}
48