NullTransformer::instance()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 7
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 2

Importance

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