Completed
Push — master ( 6bd91f...3471cf )
by Luc
11s
created

Language::getCode()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 0
1
<?php
2
3
namespace CultuurNet\UDB3;
4
5
class Language
6
{
7
    protected $code;
8
9
    /**
10
     * @param string $code
11
     */
12
    public function __construct($code)
13
    {
14
        if (!preg_match('/^[a-z]{2}$/', $code)) {
15
            throw new \InvalidArgumentException(
16
                'Invalid language code: ' . $code
17
            );
18
        }
19
        $this->code = $code;
20
    }
21
22
    /**
23
     * @return string
24
     */
25
    public function __toString()
26
    {
27
        return $this->code;
28
    }
29
30
    /**
31
     * @return string
32
     */
33
    public function getCode()
34
    {
35
        return $this->code;
36
    }
37
}
38