Completed
Pull Request — master (#274)
by Luc
05:29
created

Language   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 33
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Importance

Changes 0
Metric Value
wmc 4
lcom 0
cbo 0
dl 0
loc 33
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 9 2
A __toString() 0 4 1
A getCode() 0 4 1
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