Completed
Pull Request — master (#1)
by steven
04:42
created

Language::__construct()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 9
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 2
eloc 4
nc 2
nop 1
dl 0
loc 9
rs 9.6666
c 0
b 0
f 0
1
<?php
2
3
namespace VSV\GVQ_API\Question;
4
5
class Language
6
{
7
    /**
8
     * @var string
9
     */
10
    private $value;
11
12
    /**
13
     * @var string[]
14
     */
15
    private $supportedLanguages = ['nl', 'fr'];
16
17
    /**
18
     * @param string $value
19
     */
20
    public function __construct(string $value)
21
    {
22
        if (!in_array($value, $this->supportedLanguages)) {
23
            throw new \InvalidArgumentException(
24
                'Given language ' . $value . ' is not supported, only nl en fr are allowed.'
25
            );
26
        }
27
28
        $this->value = $value;
29
    }
30
}
31