CallableNormalizationObjectMapping   A
last analyzed

Complexity

Total Complexity 8

Size/Duplication

Total Lines 68
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 2
Bugs 0 Features 1
Metric Value
eloc 15
dl 0
loc 68
ccs 12
cts 12
cp 1
rs 10
c 2
b 0
f 1
wmc 8

7 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A getMapping() 0 8 2
A getNormalizationFieldMappings() 0 3 1
A getNormalizationType() 0 3 1
A getClass() 0 3 1
A getNormalizationLinkMappings() 0 3 1
A getNormalizationEmbeddedFieldMappings() 0 3 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Chubbyphp\Serialization\Mapping;
6
7
final class CallableNormalizationObjectMapping implements NormalizationObjectMappingInterface
8
{
9
    /**
10
     * @var string
11
     */
12
    private $class;
13
14
    /**
15
     * @var callable
16
     */
17
    private $callable;
18
19
    /**
20
     * @var NormalizationObjectMappingInterface|null
21
     */
22
    private $mapping;
23
24
    public function __construct(string $class, callable $callable)
25
    {
26
        $this->class = $class;
27
        $this->callable = $callable;
28 5
    }
29
30 5
    public function getClass(): string
31 5
    {
32 5
        return $this->class;
33
    }
34
35
    /**
36
     * @return string|null
37 1
     */
38
    public function getNormalizationType()
39 1
    {
40
        return $this->getMapping()->getNormalizationType();
41
    }
42
43
    /**
44
     * @return NormalizationFieldMappingInterface[]
45 1
     */
46
    public function getNormalizationFieldMappings(string $path): array
47 1
    {
48
        return $this->getMapping()->getNormalizationFieldMappings($path);
49
    }
50
51
    /**
52
     * @return NormalizationFieldMappingInterface[]
53
     */
54
    public function getNormalizationEmbeddedFieldMappings(string $path): array
55 1
    {
56
        return $this->getMapping()->getNormalizationEmbeddedFieldMappings($path);
57 1
    }
58
59
    /**
60
     * @return NormalizationLinkMappingInterface[]
61
     */
62
    public function getNormalizationLinkMappings(string $path): array
63
    {
64
        return $this->getMapping()->getNormalizationLinkMappings($path);
65 1
    }
66
67 1
    private function getMapping(): NormalizationObjectMappingInterface
68
    {
69
        if (null === $this->mapping) {
70
            $callable = $this->callable;
71
            $this->mapping = $callable();
72
        }
73
74
        return $this->mapping;
75 1
    }
76
}
77