Completed
Pull Request — master (#167)
by Gorka
04:49 queued 01:55
created

TaskIdType::convertToDatabaseValue()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 8
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 8
rs 9.4285
cc 2
eloc 4
nc 2
nop 2
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)
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)
33
    {
34
        return TaskId::generate($value);
35
    }
36
37
    public function getName()
38
    {
39
        return 'task_id';
40
    }
41
}
42