TaskIdType::convertToPHPValue()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 8
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 2
eloc 4
nc 2
nop 2
dl 0
loc 8
rs 9.4285
c 0
b 0
f 0
1
<?php
2
3
/*
4
 * This file is part of the Kreta package.
5
 *
6
 * (c) Beñat Espiña <[email protected]>
7
 * (c) Gorka Laucirica <[email protected]>
8
 *
9
 * For the full copyright and license information, please view the LICENSE
10
 * file that was distributed with this source code.
11
 */
12
13
declare(strict_types=1);
14
15
namespace Kreta\TaskManager\Infrastructure\Persistence\Doctrine\DBAL\Project\Task\Types;
16
17
use Doctrine\DBAL\Platforms\AbstractPlatform;
18
use Doctrine\DBAL\Types\GuidType;
19
use Kreta\TaskManager\Domain\Model\Project\Task\TaskId;
20
21
class TaskIdType extends GuidType
22
{
23
    public function convertToDatabaseValue($value, AbstractPlatform $platform) : ? string
0 ignored issues
show
Documentation introduced by
The return type could not be reliably inferred; please add a @return annotation.

Our type inference engine in quite powerful, but sometimes the code does not provide enough clues to go by. In these cases we request you to add a @return annotation as described here.

Loading history...
24
    {
25
        if ($value instanceof TaskId) {
26
            return $value->id();
27
        }
28
29
        return $value;
30
    }
31
32
    public function convertToPHPValue($value, AbstractPlatform $platform) : ? TaskId
33
    {
34
        if (null === $value) {
35
            return null;
36
        }
37
38
        return TaskId::generate($value);
39
    }
40
41
    public function getName() : string
42
    {
43
        return 'task_id';
44
    }
45
}
46