Completed
Push — 2.0 ( 359ae1...221cc7 )
by Rafał
51:27 queued 18:07
created

GeoIPReaderAdapterStub::getState()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 8

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 8
rs 10
c 0
b 0
f 0
cc 2
nc 2
nop 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace SWP\Behat\Service;
6
7
use SWP\Component\GeoIP\Reader\ReaderInterface;
8
use GeoIp2\Exception\AddressNotFoundException;
9
10
class GeoIPReaderAdapterStub implements ReaderInterface
11
{
12
    private const LOCALHOST = '127.0.0.1';
13
14
    /** @var string */
15
    protected static $country = '';
16
17
    /** @var string */
18
    protected static $state = '';
19
20
    public function getCountry(string $ipAddress): string
21
    {
22
        if (self::LOCALHOST === $ipAddress) {
23
            throw new AddressNotFoundException();
24
        }
25
26
        return static::$country;
27
    }
28
29
    public function getState(string $ipAddress): string
30
    {
31
        if (self::LOCALHOST === $ipAddress) {
32
            throw new AddressNotFoundException();
33
        }
34
35
        return static::$state;
36
    }
37
38
    public function setCountry(string $country): void
39
    {
40
        static::$country = $country;
41
    }
42
43
    public function setState(string $state): void
44
    {
45
        static::$state = $state;
46
    }
47
}
48