DefaultLookupAdapter::getCountry()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 11
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 11
ccs 4
cts 4
cp 1
rs 9.4285
c 0
b 0
f 0
cc 2
eloc 5
nc 2
nop 1
crap 2
1
<?php
2
namespace Azine\GeoBlockingBundle\Adapter;
3
4
class DefaultLookupAdapter implements GeoIpLookupAdapterInterface
5
{
6 4
    public function getCountry($visitorAddress)
7
    {
8 4
        if (!function_exists("geoip_country_code_by_name")) {
9
            // @codeCoverageIgnoreStart
10
            throw new \InvalidArgumentException("It seems, the geo-ip extension is not installed for php.");
11
            // @codeCoverageIgnoreEnd
12
        }
13 4
        $counrtyCode = @\geoip_country_code_by_name($visitorAddress);
14
15 4
        return $counrtyCode;
16
    }
17
}
18