Passed
Push — master ( 1beb50...8c44f8 )
by Gerrit
13:58
created

FixNativeMapping::assertValue()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 1 Features 1
Metric Value
cc 1
eloc 1
nc 1
nop 3
dl 0
loc 6
rs 10
c 1
b 1
f 1
1
<?php
2
/**
3
 * Copyright (C) 2019 Gerrit Addiks.
4
 * This package (including this file) was released under the terms of the GPL-3.0.
5
 * You should have received a copy of the GNU General Public License along with this program.
6
 * If not, see <http://www.gnu.org/licenses/> or send me a mail so i can send you a copy.
7
 *
8
 * @license GPL-3.0
9
 *
10
 * @author Gerrit Addiks <[email protected]>
11
 */
12
13
namespace Addiks\RDMBundle\Mapping;
14
15
use Addiks\RDMBundle\Mapping\MappingInterface;
16
use Webmozart\Assert\Assert;
17
use Addiks\RDMBundle\Hydration\HydrationContextInterface;
18
use Symfony\Component\DependencyInjection\ContainerInterface;
19
20
class FixNativeMapping implements MappingInterface
21
{
22
    public function __construct(
23
        public readonly string $jsonSerializedValue,
24
        public readonly string $origin = "unknown"
25
    ) {
26
    }
27
    
28
    public function describeOrigin(): string
29
    {
30
        return $this->origin;
31
    }
32
33
    public function collectDBALColumns(): array
34
    {
35
        return [];
36
    }
37
38
    public function resolveValue(
39
        HydrationContextInterface $context,
40
        array $dataFromAdditionalColumns
41
    ) {
42
        return json_decode($this->jsonSerializedValue, true);
43
    }
44
45
    public function revertValue(
46
        HydrationContextInterface $context,
47
        $valueFromEntityField
48
    ): array {
49
        return [];
50
    }
51
52
    public function assertValue(
53
        HydrationContextInterface $context,
54
        array $dataFromAdditionalColumns,
55
        $actualValue
56
    ): void {
57
        Assert::same($this->jsonSerializedValue, json_encode($actualValue));
58
    }
59
60
    public function wakeUpMapping(ContainerInterface $container): void
61
    {
62
    }
63
}
64