Failed Conditions
Pull Request — master (#7008)
by Grégoire
13:34 queued 01:47
created

HydrationException::invalidDiscriminatorValue()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
cc 1
eloc 4
nc 1
nop 2
dl 0
loc 6
ccs 0
cts 5
cp 0
crap 2
rs 9.4285
c 0
b 0
f 0
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Doctrine\ORM\Internal\Hydration;
6
7
use Doctrine\ORM\ORMException;
0 ignored issues
show
Bug introduced by
The type Doctrine\ORM\ORMException was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
8
9
class HydrationException extends ORMException
10
{
11
    /**
12
     * @return HydrationException
13
     */
14
    public static function nonUniqueResult()
15
    {
16
        return new self('The result returned by the query was not unique.');
17
    }
18
19
    /**
20
     * @param string $alias
21
     * @param string $parentAlias
22
     *
23
     * @return HydrationException
24
     */
25
    public static function parentObjectOfRelationNotFound($alias, $parentAlias)
26
    {
27
        return new self(sprintf(
28
            "The parent object of entity result with alias '%s' was not found. The parent alias is '%s'.",
29
            $alias,
30
            $parentAlias
31
        ));
32
    }
33
34
    /**
35
     * @param string $dqlAlias
36
     *
37
     * @return HydrationException
38
     */
39
    public static function emptyDiscriminatorValue($dqlAlias)
40
    {
41
        return new self("The DQL alias '" . $dqlAlias . "' contains an entity " .
42
            'of an inheritance hierarchy with an empty discriminator value. This means ' .
43
            'that the database contains inconsistent data with an empty ' .
44
            'discriminator value in a table row.');
45
    }
46
47
    /**
48
     * @param string $entityName
49
     * @param string $discrColumnName
50
     * @param string $dqlAlias
51
     *
52
     * @return HydrationException
53
     */
54
    public static function missingDiscriminatorColumn($entityName, $discrColumnName, $dqlAlias)
55
    {
56
        return new self(sprintf(
57
            'The discriminator column "%s" is missing for "%s" using the DQL alias "%s".',
58
            $discrColumnName,
59
            $entityName,
60
            $dqlAlias
61
        ));
62
    }
63
64
    /**
65
     * @param string $entityName
66
     * @param string $discrColumnName
67
     * @param string $dqlAlias
68
     *
69
     * @return HydrationException
70
     */
71
    public static function missingDiscriminatorMetaMappingColumn($entityName, $discrColumnName, $dqlAlias)
72
    {
73
        return new self(sprintf(
74
            'The meta mapping for the discriminator column "%s" is missing for "%s" using the DQL alias "%s".',
75
            $discrColumnName,
76
            $entityName,
77
            $dqlAlias
78
        ));
79
    }
80
81
    /**
82
     * @param string   $discrValue
83
     * @param string[] $discrMap
84
     *
85
     * @return HydrationException
86
     */
87
    public static function invalidDiscriminatorValue($discrValue, $discrMap)
88
    {
89
        return new self(sprintf(
90
            'The discriminator value "%s" is invalid. It must be one of "%s".',
91
            $discrValue,
92
            implode('", "', $discrMap)
93
        ));
94
    }
95
}
96