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

TerritoryLanguages::getISONumber()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
c 0
b 0
f 0
dl 0
loc 3
rs 10
cc 1
eloc 1
nc 1
nop 0
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