Language::__construct()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 9
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 4
c 1
b 0
f 0
dl 0
loc 9
rs 10
cc 2
nc 2
nop 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Skrill\ValueObject;
6
7
use Skrill\Exception\InvalidLangException;
8
use Skrill\ValueObject\Traits\ValueToStringTrait;
9
10
/**
11
 * Value object for language.
12
 *
13
 * @see https://en.wikipedia.org/wiki/ISO_639-1
14
 * @see https://www.skrill.com/fileadmin/content/pdf/Skrill_Quick_Checkout_Guide.pdf
15
 */
16
final class Language
17
{
18
    use ValueToStringTrait;
19
20
    /**
21
     * @param string $value
22
     *
23
     * @throws InvalidLangException
24
     */
25
    public function __construct(string $value)
26
    {
27
        $value = trim($value);
28
29
        if (!array_key_exists($value, getSkillSupportsLanguages())) {
30
            throw InvalidLangException::invalidValue();
31
        }
32
33
        $this->value = $value;
34
    }
35
}
36