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