IdentityTransformer::transform()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 8
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 8
rs 9.4285
cc 2
eloc 4
nc 2
nop 1
1
<?php
2
3
declare (strict_types = 1);
4
5
namespace HMLB\DDDBundle\Form\DataTransformer;
6
7
use HMLB\DDD\Entity\Identity;
8
use Symfony\Component\Form\DataTransformerInterface;
9
10
/**
11
 * IdentityTransformer.
12
 *
13
 * @author Hugues Maignol <[email protected]>
14
 */
15
class IdentityTransformer implements DataTransformerInterface
16
{
17
    /**
18
     * {@inheritdoc}
19
     */
20
    public function transform($value)
21
    {
22
        if (null === $value) {
23
            return;
24
        }
25
26
        return (string) $value;
27
    }
28
29
    /**
30
     * {@inheritdoc}
31
     */
32
    public function reverseTransform($value)
33
    {
34
        if (null === $value) {
35
            return;
36
        }
37
38
        return new Identity($value);
39
    }
40
}
41