LanguageCode   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 16
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 3
lcom 0
cbo 2
dl 0
loc 16
rs 10
c 0
b 0
f 0
ccs 8
cts 8
cp 1

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A guard() 0 8 2
1
<?php
2
3
declare(strict_types=1);
4
5
namespace PhpValueObjects\Geography;
6
7
use PhpValueObjects\AbstractValueObject;
8
use Symfony\Component\Intl\Exception\MissingResourceException;
9
use Symfony\Component\Intl\Languages;
10
11
abstract class LanguageCode extends AbstractValueObject
12
{
13 9
    public function __construct(string $value)
14
    {
15 9
        parent::__construct($value);
16 3
    }
17
18 9
    protected function guard($value): void
19
    {
20
        try {
21 9
            Languages::getName($value);
22 6
        } catch (MissingResourceException $exception) {
23 6
            $this->throwException($value);
24
        }
25 3
    }
26
}
27