fromInvalidKeyCharacters()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 7

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 1

Importance

Changes 0
Metric Value
cc 1
nc 1
nop 1
dl 0
loc 7
ccs 3
cts 3
cp 1
crap 1
rs 10
c 0
b 0
f 0
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 2 View Code Duplication
    public static function fromKeyAndInvalidTTL(string $key, $ttl) : self
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
11
    {
12 2
        return new self(sprintf(
13 2
            'TTL for "%s" should be defined by an integer or a DateInterval, but %s is given.',
14
            $key,
15 2
            is_object($ttl) ? get_class($ttl) : gettype($ttl)
16
        ));
17
    }
18
19 1
    public static function fromInvalidKeyCharacters(string $invalidKey) : self
20
    {
21 1
        return new self(sprintf(
22 1
            'Key "%s" is in an invalid format - must not contain characters: {}()/\@:',
23
            $invalidKey
24
        ));
25
    }
26
27 1 View Code Duplication
    public static function fromInvalidType($invalidKey) : self
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
28
    {
29 1
        return new self(sprintf(
30 1
            'Key was not a valid type. Expected string, received %s',
31 1
            is_object($invalidKey) ? get_class($invalidKey) : gettype($invalidKey)
32
        ));
33
    }
34
35 1
    public static function fromEmptyKey() : self
36
    {
37 1
        return new self('Requested key was an empty string.');
38
    }
39
40 1 View Code Duplication
    public static function fromNonIterableKeys($invalidKeys) : self
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
41
    {
42 1
        return new self(sprintf(
43 1
            'Keys passed were not iterable (i.e. \Traversable or array), received: %s',
44 1
            is_object($invalidKeys) ? get_class($invalidKeys) : gettype($invalidKeys)
45
        ));
46
    }
47
48 1 View Code Duplication
    public static function fromNonIterableValues($invalidValues) : self
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
49
    {
50 1
        return new self(sprintf(
51 1
            'Values passed were not iterable (i.e. \Traversable or array), received: %s',
52 1
            is_object($invalidValues) ? get_class($invalidValues) : gettype($invalidValues)
53
        ));
54
    }
55
}
56