Completed
Push — master ( 26ecbc...8c0c5d )
by Maciej
14s
created

parentClassRequired()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 10

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 10
ccs 0
cts 10
cp 0
rs 9.9332
c 0
b 0
f 0
cc 1
nc 1
nop 2
crap 2
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Doctrine\ODM\MongoDB\PersistentCollection;
6
7
use Doctrine\ODM\MongoDB\MongoDBException;
8
use Throwable;
9
use function sprintf;
10
11
/**
12
 * MongoDB ODM PersistentCollection Exception.
13
 */
14
class PersistentCollectionException extends MongoDBException
15
{
16
    public static function directoryNotWritable() : self
17
    {
18
        return new self('Your PersistentCollection directory must be writable.');
19
    }
20
21
    public static function directoryRequired() : self
22
    {
23
        return new self('You must configure a PersistentCollection directory. See docs for details.');
24
    }
25
26
    public static function namespaceRequired() : self
27
    {
28
        return new self('You must configure a PersistentCollection namespace. See docs for details');
29
    }
30
31
    public static function invalidParameterTypeHint(
32
        string $className,
33
        string $methodName,
34
        string $parameterName,
35
        ?Throwable $previous = null
36
    ) : self {
37
        return new self(
38
            sprintf(
39
                'The type hint of parameter "%s" in method "%s" in class "%s" is invalid.',
40
                $parameterName,
41
                $methodName,
42
                $className
43
            ),
44
            0,
45
            $previous
46
        );
47
    }
48
49
    public static function invalidReturnTypeHint(string $className, string $methodName, ?Throwable $previous = null) : self
50
    {
51
        return new self(
52
            sprintf(
53
                'The return type of method "%s" in class "%s" is invalid.',
54
                $methodName,
55
                $className
56
            ),
57
            0,
58
            $previous
59
        );
60
    }
61
62
    public static function parentClassRequired(string $className, string $methodName) : self
63
    {
64
        return new self(
65
            sprintf(
66
                'The method "%s" in class "%s" defines a parent return type, but the class does not extend any class.',
67
                $methodName,
68
                $className
69
            )
70
        );
71
    }
72
73
    public static function ownerRequiredToLoadCollection() : self
74
    {
75
        return new self('Cannot load persistent collection without an owner.');
76
    }
77
}
78