GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.

TrackingIdDoctrineType::getName()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %
Metric Value
dl 0
loc 4
rs 10
cc 1
eloc 2
nc 1
nop 0
1
<?php
2
/*
3
 * This file is part of the prooph/php-ddd-cargo-sample.
4
 * (c) Alexander Miertsch <[email protected]>
5
 *
6
 * For the full copyright and license information, please view the LICENSE
7
 * file that was distributed with this source code.
8
 *
9
 * Date: 06.12.15 - 17:25
10
 */
11
12
namespace Codeliner\CargoBackend\Infrastructure\Persistence\Doctrine\Type;
13
14
use Codeliner\CargoBackend\Model\Cargo\TrackingId;
15
use Doctrine\DBAL\Platforms\AbstractPlatform;
16
use Doctrine\DBAL\Types\ConversionException;
17
use Ramsey\Uuid\Doctrine\UuidType;
18
19
/**
20
 * Class TrackingIdDoctrineType
21
 * Doctrine type of a a Cargo\TrackingId
22
 *
23
 * @package Codeliner\CargoBackend\Infrastructure\Persistence\Doctrine\Type
24
 */
25
final class TrackingIdDoctrineType extends UuidType
26
{
27
    const NAME = 'cargo_tracking_id';
28
29
    /**
30
     * {@inheritdoc}
31
     *
32
     * @param string|null                               $value
33
     * @param AbstractPlatform $platform
34
     */
35
    public function convertToPHPValue($value, AbstractPlatform $platform): TrackingId
36
    {
37
        if (empty($value)) {
38
            return null;
39
        }
40
41
        if ($value instanceof TrackingId) {
42
            return $value;
43
        }
44
45
        try {
46
            $value = TrackingId::fromString($value);
47
        } catch (\Exception $ex) {
48
            throw ConversionException::conversionFailed($value, self::NAME);
49
        }
50
51
        return $value;
52
    }
53
54
    /**
55
     * {@inheritdoc}
56
     *
57
     * @param TrackingId|null $value
58
     * @param AbstractPlatform $platform
59
     */
60
    public function convertToDatabaseValue($value, AbstractPlatform $platform)
61
    {
62
        if (null === $value) {
63
            return null;
64
        }
65
66
        if ($value instanceof TrackingId) {
67
            return $value->toString();
68
        }
69
70
        throw ConversionException::conversionFailed($value, self::NAME);
71
    }
72
73
    /**
74
     * @inheritdoc
75
     */
76
    public function getName()
77
    {
78
        return self::NAME;
79
    }
80
}
81