MappingException::classIsNotAValidDocument()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 1
1
<?php
2
3
namespace Doctrine\ODM\CouchDB\Mapping;
4
5
/**
6
 * Mapping exception class
7
 *
8
 * @license     http://www.opensource.org/licenses/lgpl-license.php LGPL
9
 * @link        www.doctrine-project.com
10
 * @since       1.0
11
 * @author      Benjamin Eberlei <[email protected]>
12
 * @author      Lukas Kahwe Smith <[email protected]>
13
 */
14
class MappingException extends \Exception
15
{
16
    public static function classNotFound($className)
17
    {
18
        return new self('The class: ' . $className . ' could not be found');
19
    }
20
21
    public static function classIsNotAValidDocument($className)
22
    {
23
        return new self('Class '.$className.' is not a valid document or mapped super class.');
24
    }
25
26
    public static function reflectionFailure($document, \ReflectionException $previousException)
27
    {
28
        return new self('An error occurred in ' . $document, 0, $previousException);
29
    }
30
31
    public static function fileMappingDriversRequireConfiguredDirectoryPath()
32
    {
33
        return new self('File mapping drivers must have a valid directory path, however the given path seems to be incorrect!');
34
    }
35
36
    public static function classNotMapped()
37
    {
38
        return new self();
39
    }
40
41
    public static function noTypeSpecified()
42
    {
43
        return new self();
44
    }
45
46
    public static function duplicateFieldMapping($className, $fieldName)
47
    {
48
        return new self("Cannot map duplicate field '" . $className . "::" . $fieldName . "'.");
49
    }
50
51
    public static function mappingNotFound($className, $fieldName)
52
    {
53
        return new self("No mapping found for field '$fieldName' in class '$className'.");
54
    }
55
56
    public static function invalidInheritanceRoot($className, $parents)
57
    {
58
        return new self(
59
            "Class '" . $className . "' cannot be the root of an inheritance hierachy, because it has " .
60
            "parent classes: " . implode(", ", $parents)
61
        );
62
    }
63
    
64
    public static function mappingFileNotFound($className, $filename)
65
    {
66
        return new self(
67
            "Mapping file:  '" . $filename . "' not found, for class: '" . $className . "'."
68
        );
69
    }
70
}
71