Completed
Pull Request — master (#276)
by Kristof
07:05
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
     * @param $code
10
     */
11
    public function __construct($code)
12
    {
13
        if (!preg_match('/^[a-z]{2}$/', $code)) {
14
            throw new \InvalidArgumentException(
15
                'Invalid language code: ' . $code
16
            );
17
        }
18
        $this->code = $code;
19
    }
20
21
    public function __toString()
22
    {
23
        return $this->code;
24
    }
25
26
    public function getCode()
27
    {
28
        return $this->code;
29
    }
30
}
31