Failed Conditions
Pull Request — master (#1)
by Jonathan
13:22 queued 10:46
created

MappingException   A

Complexity

Total Complexity 7

Size/Duplication

Total Lines 70
Duplicated Lines 0 %

Test Coverage

Coverage 41.18%

Importance

Changes 0
Metric Value
wmc 7
dl 0
loc 70
ccs 7
cts 17
cp 0.4118
rs 10
c 0
b 0
f 0

6 Methods

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