Passed
Pull Request — master (#25)
by
unknown
13:18
created

ODMType::getDeserializationContext()   A

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 0
Metric Value
eloc 1
c 0
b 0
f 0
dl 0
loc 3
ccs 2
cts 2
cp 1
rs 10
cc 1
nc 1
nop 0
crap 1
1
<?php
2
/*
3
 * This file is part of Goodwix Doctrine JSON ODM.
4
 *
5
 * For the full copyright and license information, please view the LICENSE
6
 * file that was distributed with this source code.
7
 */
8
9
namespace Goodwix\DoctrineJsonOdm\Type;
10
11
use Symfony\Component\Serializer\SerializerInterface;
12
13
class ODMType extends AbstractODMType
14
{
15 5
    public static function registerODMType(string $entityClass, SerializerInterface $serializer): void
16
    {
17 5
        if (!class_exists($entityClass) && !interface_exists($entityClass)) {
18 1
            throw new \DomainException(sprintf('Class or interface "%s" does not exist.', $entityClass));
19
        }
20
21 4
        self::addType($entityClass, static::class);
22
23
        /** @var ODMType $type */
24 4
        $type = self::getType($entityClass);
25 4
        $type->setEntityClass($entityClass);
26 4
        $type->setSerializer($serializer);
27
    }
28
29
}
30