NullTransformer::transformToHttp()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

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