Passed
Push — master ( 48948a...a5130b )
by Christian
02:28
created

InvalidArgument   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 27
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 4
eloc 8
c 1
b 0
f 0
dl 0
loc 27
rs 10

4 Methods

Rating   Name   Duplication   Size   Complexity  
A invalidTTL() 0 3 1
A __construct() 0 6 1
A invalidKey() 0 3 1
A invalidIterable() 0 3 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace RemotelyLiving\PHPCacheAdapter\Exceptions;
6
7
use Psr\Cache;
8
use Psr\SimpleCache;
9
10
// phpcs:disable
11
final class InvalidArgument extends RuntimeError implements Cache\InvalidArgumentException, SimpleCache\InvalidArgumentException
12
{
13
    private function __construct(string $message = '', int $code = 0, \Throwable $previous = null)
14
    {
15
        parent::__construct(
16
            $message,
17
            $code,
18
            $previous
19
        );
20
    }
21
22
    /**
23
     * @param mixed $key
24
     */
25
    public static function invalidKey($key): self
26
    {
27
        return new self(var_export($key, true) . ' is not a valid cache key');
28
    }
29
30
    public static function invalidTTL(): self
31
    {
32
        return new self('TTL must be an integer or \DateTime');
33
    }
34
35
    public static function invalidIterable(): self
36
    {
37
        return new self('Value must be iterable');
38
    }
39
}
40
// phpcs:enable