HistoricCountries   A
last analyzed

Complexity

Total Complexity 8

Size/Duplication

Total Lines 78
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 8
dl 0
loc 78
rs 10
c 0
b 0
f 0

7 Methods

Rating   Name   Duplication   Size   Complexity  
A getISONumber() 0 3 1
A getByAlpha2() 0 3 1
A getIndexDefinition() 0 7 1
A arrayToEntry() 0 9 2
A getByNumericCode() 0 3 1
A getByAlpha3() 0 3 1
A getByAlpha4() 0 3 1
1
<?php
2
3
namespace Sokil\IsoCodes\Database;
4
5
use Sokil\IsoCodes\AbstractDatabase;
6
use Sokil\IsoCodes\Database\HistoricCountries\Country;
7
8
class HistoricCountries extends AbstractDatabase
9
{
10
    /**
11
     * @return string
12
     */
13
    public static function getISONumber()
14
    {
15
        return '3166-3';
16
    }
17
18
    /**
19
     * @param array $entry
20
     *
21
     * @return Country
22
     */
23
    protected function arrayToEntry(array $entry)
24
    {
25
        return new Country(
26
            $entry['name'],
27
            $entry['alpha_4'],
28
            $entry['alpha_3'],
29
            $entry['alpha_2'],
30
            $entry['withdrawal_date'],
31
            !empty($entry['numeric']) ? (int)$entry['numeric'] : null
32
        );
33
    }
34
35
    /**
36
     * @return array
37
     */
38
    protected function getIndexDefinition()
39
    {
40
        return [
41
            'alpha_4',
42
            'alpha_3',
43
            'alpha_2',
44
            'numeric'
45
        ];
46
    }
47
48
    /**
49
     * @param string $code
50
     *
51
     * @return null|Country
52
     */
53
    public function getByAlpha4($code)
54
    {
55
        return $this->find('alpha_4', $code);
56
    }
57
58
    /**
59
     * @param string $code
60
     *
61
     * @return null|Country
62
     */
63
    public function getByAlpha3($code)
64
    {
65
        return $this->find('alpha_3', $code);
66
    }
67
68
    /**
69
     * @param string $code
70
     *
71
     * @return null|Country
72
     */
73
    public function getByAlpha2($code)
74
    {
75
        return $this->find('alpha_2', $code);
76
    }
77
78
    /**
79
     * @param int $code
80
     *
81
     * @return null|Country
82
     */
83
    public function getByNumericCode($code)
84
    {
85
        return $this->find('numeric', $code);
86
    }
87
}
88