Completed
Pull Request — master (#275)
by Kristof
06:32
created

Language   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 26
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Importance

Changes 0
Metric Value
wmc 4
lcom 0
cbo 0
dl 0
loc 26
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
     * @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