Passed
Pull Request — master (#3)
by Artem
02:31
created

TerritoryLanguages   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 40
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 4
dl 0
loc 40
rs 10
c 0
b 0
f 0

4 Methods

Rating   Name   Duplication   Size   Complexity  
A getByAlpha2() 0 3 1
A getISONumber() 0 3 1
A arrayToEntry() 0 5 1
A getIndexDefinition() 0 4 1
1
<?php
2
3
namespace Sokil\IsoCodes\Database;
4
5
use Sokil\IsoCodes\AbstractDatabase;
6
use Sokil\IsoCodes\Database\Territory\Territory;
7
8
class TerritoryLanguages extends AbstractDatabase
9
{
10
    const UNKNOWN_COUNTRY = 'ZZ';
11
12
    public static function getISONumber()
13
    {
14
        return 'territory_languages';
15
    }
16
17
    /**
18
     * @param array $entry
19
     *
20
     * @return Territory
21
     */
22
    protected function arrayToEntry(array $entry)
23
    {
24
        return new Territory(
25
            $entry['alpha_2'],
26
            $entry['languages']
27
        );
28
    }
29
30
    /**
31
     * @return array
32
     */
33
    protected function getIndexDefinition()
34
    {
35
        return [
36
            'alpha_2',
37
        ];
38
    }
39
40
    /**
41
     * @param string $alpha2
42
     *
43
     * @return null|Territory
44
     */
45
    public function getByAlpha2($alpha2)
46
    {
47
        return $this->find('alpha_2', $alpha2);
48
    }
49
50
51
}
52