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

CountryTransformer::input()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 7
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 2.0625

Importance

Changes 0
Metric Value
eloc 3
dl 0
loc 7
ccs 3
cts 4
cp 0.75
rs 10
c 0
b 0
f 0
cc 2
nc 2
nop 1
crap 2.0625
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
}