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

TerritoryLanguages::getByAlpha2()   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 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
    public static function getISONumber()
11
    {
12
        return 'territory_languages';
13
    }
14
15
    /**
16
     * @param array $entry
17
     *
18
     * @return Territory
19
     */
20
    protected function arrayToEntry(array $entry)
21
    {
22
        return new Territory(
23
            $entry['alpha_2'],
24
            $entry['languages']
25
        );
26
    }
27
28
    /**
29
     * @return array
30
     */
31
    protected function getIndexDefinition()
32
    {
33
        return [
34
            'alpha_2',
35
        ];
36
    }
37
38
    /**
39
     * @param string $alpha2
40
     *
41
     * @return null|Territory
42
     */
43
    public function getByAlpha2($alpha2)
44
    {
45
        return $this->find('alpha_2', $alpha2);
46
    }
47
48
49
}
50