Locale::guard()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 8

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 5
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 8
rs 10
c 0
b 0
f 0
cc 2
nc 2
nop 1
ccs 5
cts 5
cp 1
crap 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\Locales;
10
11
abstract class Locale extends AbstractValueObject
12
{
13 18
    protected function guard($value): void
14
    {
15
        try {
16 18
            Locales::getName($value);
17 6
        } catch (MissingResourceException $exception) {
18 6
            $this->throwException($value);
19
        }
20 12
    }
21
}
22