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

MappingException::classNotFoundInNamespaces()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 5
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 6
rs 9.4285
c 0
b 0
f 0
ccs 5
cts 5
cp 1
cc 1
eloc 4
nc 1
nop 2
crap 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