Failed Conditions
Pull Request — master (#2)
by Jonathan
03:29
created

MappingException   A

Complexity

Total Complexity 7

Size/Duplication

Total Lines 54
Duplicated Lines 0 %

Test Coverage

Coverage 46.15%

Importance

Changes 0
Metric Value
wmc 7
dl 0
loc 54
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
declare(strict_types=1);
4
5
namespace Doctrine\Common\Persistence\Mapping;
6
7
use function implode;
8
use function sprintf;
9
10
/**
11
 * A MappingException indicates that something is wrong with the mapping setup.
12
 */
13
class MappingException extends \Exception
14
{
15
    /**
16
     * @param string[] $namespaces
17
     */
18 1
    public static function classNotFoundInNamespaces(string $className, array $namespaces) : self
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
    public static function pathRequired() : self
28
    {
29
        return new self('Specifying the paths to your entities is required ' .
30
            'in the AnnotationDriver to retrieve all class names.');
31
    }
32
33
    public static function fileMappingDriversRequireConfiguredDirectoryPath(?string $path = null) : self
34
    {
35
        if (! empty($path)) {
36
            $path = '[' . $path . ']';
37
        }
38
39
        return new self(sprintf(
40
            'File mapping drivers must have a valid directory path, ' .
41
            'however the given path %s seems to be incorrect!',
42
            $path
43
        ));
44
    }
45
46 2
    public static function mappingFileNotFound(string $entityName, string $fileName) : self
47
    {
48 2
        return new self(sprintf(
49 2
            "No mapping file found named '%s' for class '%s'.",
50 2
            $fileName,
51 2
            $entityName
52
        ));
53
    }
54
55
    public static function invalidMappingFile(string $entityName, string $fileName) : self
56
    {
57
        return new self(sprintf(
58
            "Invalid mapping file '%s' for class '%s'.",
59
            $fileName,
60
            $entityName
61
        ));
62
    }
63
64 1
    public static function nonExistingClass(string $className) : self
65
    {
66 1
        return new self(sprintf("Class '%s' does not exist", $className));
67
    }
68
}
69