Passed
Push — master ( 331013...49242a )
by Derek Stephen
04:04
created

CountryTransformer   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 14
Duplicated Lines 0 %

Test Coverage

Coverage 50%

Importance

Changes 0
Metric Value
wmc 4
eloc 5
dl 0
loc 14
ccs 3
cts 6
cp 0.5
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A output() 0 3 2
A input() 0 7 2
1
<?php
2
3
namespace Bone\User\Form\Transformer;
4
5
use Del\Entity\Country;
6
use Del\Factory\CountryFactory;
7
use Del\Form\Field\TransformerInterface;
8
9
class CountryTransformer implements TransformerInterface
10
{
11 1
    public function input($data): string
12
    {
13 1
        if ($data instanceof Country) {
14
            return $data->getIso();
15
        }
16
17 1
        return $data;
18
    }
19
20
    public function output(string $value)
21
    {
22
        return empty($value) ? '' : CountryFactory::generate($value);
23
    }
24
25
}