IdentityTransformer   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 26
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 4
c 1
b 0
f 0
lcom 0
cbo 1
dl 0
loc 26
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A transform() 0 8 2
A reverseTransform() 0 8 2
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