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

InvalidArgumentException   A

Complexity

Total Complexity 8

Size/Duplication

Total Lines 41
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 8
lcom 1
cbo 0
dl 0
loc 41
ccs 17
cts 17
cp 1
rs 10
c 0
b 0
f 0

5 Methods

Rating   Name   Duplication   Size   Complexity  
A fromInvalidKeyCharacters() 0 7 1
A fromInvalidType() 0 7 2
A fromEmptyKey() 0 4 1
A fromNonIterableKeys() 0 7 2
A fromNonIterableValues() 0 7 2
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