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

RetrievesGeoIpTimezone::getGeoIpTimezone()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 7
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 4
nc 1
nop 1
dl 0
loc 7
rs 10
c 1
b 0
f 0
1
<?php
2
3
namespace JamesMills\LaravelTimezone\Traits;
4
5
trait RetrievesGeoIpTimezone
6
{
7
    protected function getGeoIpTimezone(?string $ip): array
8
    {
9
        $info = geoip()->getLocation($ip);
10
11
        return [
12
            'timezone' => ($info['time_zone'] ?? [])['name'] ?? ($info['timezone'] ?? null),
13
            'default' => $info['default'] ?? false,
14
        ];
15
    }
16
}
17