Failed Conditions
Push — master ( ec2bd1...5afe97 )
by Jonathan
41s
created

MappingException   A

Complexity

Total Complexity 7

Size/Duplication

Total Lines 82
Duplicated Lines 0 %

Test Coverage

Coverage 46.15%

Importance

Changes 0
Metric Value
wmc 7
dl 0
loc 82
rs 10
c 0
b 0
f 0
ccs 12
cts 26
cp 0.4615

6 Methods

Rating   Name   Duplication   Size   Complexity  
A mappingFileNotFound() 0 6 1
A invalidMappingFile() 0 6 1
A nonExistingClass() 0 3 1
A fileMappingDriversRequireConfiguredDirectoryPath() 0 10 2
A classNotFoundInNamespaces() 0 6 1
A pathRequired() 0 4 1
1
<?php
2
3
namespace Doctrine\Common\Persistence\Mapping;
4
5
use Exception;
6
use function implode;
7
use function sprintf;
8
9
/**
10
 * A MappingException indicates that something is wrong with the mapping setup.
11
 */
12
class MappingException extends Exception
13
{
14
    /**
15
     * @param string   $className
16
     * @param string[] $namespaces
17
     *
18
     * @return self
19
     */
20 1
    public static function classNotFoundInNamespaces($className, $namespaces)
21
    {
22 1
        return new self(sprintf(
23 1
            "The class '%s' was not found in the chain configured namespaces %s",
24 1
            $className,
25 1
            implode(', ', $namespaces)
26
        ));
27
    }
28
29
    /**
30
     * @return self
31
     */
32
    public static function pathRequired()
33
    {
34
        return new self('Specifying the paths to your entities is required ' .
35
            'in the AnnotationDriver to retrieve all class names.');
36
    }
37
38
    /**
39
     * @param string|null $path
40
     *
41
     * @return self
42
     */
43
    public static function fileMappingDriversRequireConfiguredDirectoryPath($path = null)
44
    {
45
        if (! empty($path)) {
46
            $path = '[' . $path . ']';
47
        }
48
49
        return new self(sprintf(
50
            'File mapping drivers must have a valid directory path, ' .
51
            'however the given path %s seems to be incorrect!',
52
            $path
53
        ));
54
    }
55
56
    /**
57
     * @param string $entityName
58
     * @param string $fileName
59
     *
60
     * @return self
61
     */
62 2
    public static function mappingFileNotFound($entityName, $fileName)
63
    {
64 2
        return new self(sprintf(
65 2
            "No mapping file found named '%s' for class '%s'.",
66 2
            $fileName,
67 2
            $entityName
68
        ));
69
    }
70
71
    /**
72
     * @param string $entityName
73
     * @param string $fileName
74
     *
75
     * @return self
76
     */
77
    public static function invalidMappingFile($entityName, $fileName)
78
    {
79
        return new self(sprintf(
80
            "Invalid mapping file '%s' for class '%s'.",
81
            $fileName,
82
            $entityName
83
        ));
84
    }
85
86
    /**
87
     * @param string $className
88
     *
89
     * @return self
90
     */
91 1
    public static function nonExistingClass($className)
92
    {
93 1
        return new self(sprintf("Class '%s' does not exist", $className));
94
    }
95
}
96