TaskIdType   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 25
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Importance

Changes 0
Metric Value
dl 0
loc 25
rs 10
c 0
b 0
f 0
wmc 5
lcom 0
cbo 2

3 Methods

Rating   Name   Duplication   Size   Complexity  
A convertToDatabaseValue() 0 8 2
A convertToPHPValue() 0 8 2
A getName() 0 4 1
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