CountryTransformer::output()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
cc 2
eloc 1
c 1
b 0
f 1
nc 2
nop 1
dl 0
loc 3
rs 10
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Del\Form\Transformer;
6
7
use Del\Entity\Country;
8
use Del\Factory\CountryFactory;
9
use Del\Form\Field\TransformerInterface;
10
11
class CountryTransformer implements TransformerInterface
12
{
13
    public function input($data): string
14
    {
15
        if ($data instanceof Country) {
16
            return $data->getIso();
17
        }
18
19
        return $data;
20
    }
21
22
    public function output(string $value)
23
    {
24
        return empty($value) ? '' : CountryFactory::generate($value);
25
    }
26
}
27