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

RetrievesGeoIpTimezone   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 9
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 5
dl 0
loc 9
rs 10
c 1
b 0
f 0
wmc 1

1 Method

Rating   Name   Duplication   Size   Complexity  
A getGeoIpTimezone() 0 7 1
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