Scripts::arrayToEntry()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
c 0
b 0
f 0
dl 0
loc 6
rs 9.4285
cc 1
eloc 4
nc 1
nop 1
1
<?php
2
3
namespace Sokil\IsoCodes\Database;
4
5
use Sokil\IsoCodes\AbstractDatabase;
6
use Sokil\IsoCodes\Database\Scripts\Script;
7
8
class Scripts extends AbstractDatabase
9
{
10
    /**
11
     * @return string
12
     */
13
    public static function getISONumber()
14
    {
15
        return '15924';
16
    }
17
18
    /**
19
     * @param array $entry
20
     *
21
     * @return Script
22
     */
23
    protected function arrayToEntry(array $entry)
24
    {
25
        return new Script(
26
            $entry['name'],
27
            $entry['alpha_4'],
28
            (int)$entry['numeric']
29
        );
30
    }
31
32
    /**
33
     * @return array
34
     */
35
    protected function getIndexDefinition()
36
    {
37
        return [
38
            'alpha_4',
39
            'numeric'
40
        ];
41
    }
42
43
    /**
44
     * @param string $alpha4
45
     *
46
     * @return null|Script
47
     */
48
    public function getByAlpha4($alpha4)
49
    {
50
        return $this->find('alpha_4', $alpha4);
51
    }
52
53
    /**
54
     * @param int $code
55
     *
56
     * @return null|Script
57
     */
58
    public function getByNumericCode($code)
59
    {
60
        return $this->find('numeric', $code);
61
    }
62
}
63