Currency::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
ccs 3
cts 3
cp 1
cc 1
nc 1
nop 1
crap 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace PhpValueObjects\Money;
6
7
use PhpValueObjects\AbstractValueObject;
8
use Symfony\Component\Intl\Currencies;
9
use Symfony\Component\Intl\Exception\MissingResourceException;
10
11
abstract class Currency extends AbstractValueObject
12
{
13 15
    public function __construct(string $value)
14
    {
15 15
        parent::__construct($value);
16 12
    }
17
18 15
    protected function guard($value): void
19
    {
20
        try {
21 15
            Currencies::getName($value);
22 3
        } catch (MissingResourceException $exception) {
23 3
            $this->throwException($value);
24
        }
25 12
    }
26
}
27