NullTransformer   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 35
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 4
eloc 7
c 1
b 0
f 0
dl 0
loc 35
ccs 8
cts 8
cp 1
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A transformFromHttp() 0 3 1
A instance() 0 7 2
A transformToHttp() 0 3 1
1
<?php
2
3
namespace Bdf\Form\Transformer;
4
5
use Bdf\Form\ElementInterface;
6
7
/**
8
 * Null object for form transformer
9
 */
10
final class NullTransformer implements TransformerInterface
11
{
12
    /**
13
     * @var NullTransformer|null
14
     */
15
    private static $instance;
16
17
    /**
18
     * {@inheritdoc}
19
     */
20 104
    public function transformToHttp($value, ElementInterface $input)
21
    {
22 104
        return $value;
23
    }
24
25
    /**
26
     * {@inheritdoc}
27
     */
28 320
    public function transformFromHttp($value, ElementInterface $input)
29
    {
30 320
        return $value;
31
    }
32
33
    /**
34
     * Get the null transformer instance
35
     *
36
     * @return static
37
     */
38 626
    public static function instance(): self
39
    {
40 626
        if (self::$instance) {
41 626
            return self::$instance;
42
        }
43
44 1
        return self::$instance = new self();
45
    }
46
}
47