-
Notifications
You must be signed in to change notification settings - Fork 0
/
AddressValueObjectCollectionType.php
41 lines (34 loc) · 1.15 KB
/
AddressValueObjectCollectionType.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
<?php
/*
* Copyright (c) Fusonic GmbH. All rights reserved.
* Licensed under the MIT License. See LICENSE file in the project root for license information.
*/
declare(strict_types=1);
namespace Fusonic\DDDExtensions\Tests\Doctrine\Types;
use Doctrine\DBAL\Platforms\AbstractPlatform;
use Fusonic\DDDExtensions\Doctrine\Types\ValueObjectType;
use Fusonic\DDDExtensions\Tests\Domain\AddressValueObject;
/**
* @extends ValueObjectType<AddressValueObject>
*/
final class AddressValueObjectCollectionType extends ValueObjectType
{
public function getName(): string
{
return 'addressValueObject_collection';
}
/**
* @throws \JsonException
*/
public function convertToDatabaseValue(mixed $value, AbstractPlatform $platform): ?string
{
return self::serializeArray($value, static fn (AddressValueObject $object) => AddressValueObjectType::fromObject($object));
}
/**
* @throws \JsonException
*/
public function convertToPHPValue(mixed $value, AbstractPlatform $platform): mixed
{
return self::deserializeArray($value, static fn (array $data) => AddressValueObjectType::toObject($data));
}
}