InvalidArgument::invalidIterable()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

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