Completed
Push — master ( a00769...7f1214 )
by Grégoire
15s queued 11s
created

HydratorException::hydratorNamespaceRequired()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 4
ccs 0
cts 2
cp 0
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
crap 2
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Doctrine\ODM\MongoDB\Hydrator;
6
7
use Doctrine\ODM\MongoDB\MongoDBException;
8
use function sprintf;
9
10
/**
11
 * MongoDB ODM Hydrator Exception
12
 */
13
final class HydratorException extends MongoDBException
14
{
15
    public static function hydratorDirectoryNotWritable() : self
16
    {
17
        return new self('Your hydrator directory must be writable.');
18
    }
19
20
    public static function hydratorDirectoryRequired() : self
21
    {
22
        return new self('You must configure a hydrator directory. See docs for details.');
23
    }
24
25
    public static function hydratorNamespaceRequired() : self
26
    {
27
        return new self('You must configure a hydrator namespace. See docs for details');
28
    }
29
30 4
    public static function associationTypeMismatch(string $className, string $fieldName, string $expectedType, string $actualType)
31
    {
32 4
        return new self(sprintf(
33 4
            'Expected association for field "%s" in document of type "%s" to be of type "%s", "%s" received.',
34 4
            $fieldName,
35 4
            $className,
36 4
            $expectedType,
37 4
            $actualType
38
        ));
39
    }
40
41 2
    public static function associationItemTypeMismatch(string $className, string $fieldName, $key, string $expectedType, string $actualType)
42
    {
43 2
        return new self(sprintf(
44 2
            'Expected association item with key "%s" for field "%s" in document of type "%s" to be of type "%s", "%s" received.',
45 2
            $key,
46 2
            $fieldName,
47 2
            $className,
48 2
            $expectedType,
49 2
            $actualType
50
        ));
51
    }
52
}
53