Completed
Pull Request — master (#15)
by James
06:46
created

fromInvalidKeyCharacters()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 7
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 7
ccs 3
cts 3
cp 1
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 4
nc 1
nop 1
crap 1
1
<?php
2
declare(strict_types = 1);
3
4
namespace Roave\DoctrineSimpleCache\Exception;
5
6
class InvalidArgumentException
7
    extends \InvalidArgumentException
8
    implements \Psr\SimpleCache\InvalidArgumentException
9
{
10 1
    public static function fromInvalidKeyCharacters(string $invalidKey) : self
11
    {
12 1
        return new self(sprintf(
13 1
            'Key "%s" is in an invalid format - must not contain characters: {}()/\@:',
14
            $invalidKey
15
        ));
16
    }
17
18 1
    public static function fromInvalidType($invalidKey) : self
19
    {
20 1
        return new self(sprintf(
21 1
            'Key was not a valid type. Expected string, received %s',
22 1
            is_object($invalidKey) ? get_class($invalidKey) : gettype($invalidKey)
23
        ));
24
    }
25
26 1
    public static function fromEmptyKey() : self
27
    {
28 1
        return new self('Requested key was an empty string.');
29
    }
30
31 1
    public static function fromNonIterableKeys($invalidKeys) : self
32
    {
33 1
        return new self(sprintf(
34 1
            'Keys passed were not iterable (i.e. \Traversable or array), received: %s',
35 1
            is_object($invalidKeys) ? get_class($invalidKeys) : gettype($invalidKeys)
36
        ));
37
    }
38
39 1
    public static function fromNonIterableValues($invalidValues) : self
40
    {
41 1
        return new self(sprintf(
42 1
            'Values passed were not iterable (i.e. \Traversable or array), received: %s',
43 1
            is_object($invalidValues) ? get_class($invalidValues) : gettype($invalidValues)
44
        ));
45
    }
46
}
47