CountryTransformer   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 14
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
eloc 5
c 1
b 0
f 1
dl 0
loc 14
rs 10
wmc 4

2 Methods

Rating   Name   Duplication   Size   Complexity  
A output() 0 3 2
A input() 0 7 2
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