InvalidKeyException   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 18
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Importance

Changes 0
Metric Value
wmc 2
lcom 0
cbo 0
dl 0
loc 18
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A forKey() 0 7 2
1
<?php
2
3
/**
4
 * This file is part of the Cubiche package.
5
 *
6
 * Copyright (c) Cubiche
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
namespace Cubiche\Core\Storage\Exception;
13
14
use InvalidArgumentException;
15
use Exception;
16
17
/**
18
 * InvalidKeyException class.
19
 *
20
 * @author Ivannis Suárez Jerez <[email protected]>
21
 */
22
class InvalidKeyException extends InvalidArgumentException
23
{
24
    /**
25
     * Creates an exception for an invalid key.
26
     *
27
     * @param mixed          $key
28
     * @param Exception|null $cause
29
     *
30
     * @return InvalidKeyException
31
     */
32
    public static function forKey($key, Exception $cause = null)
33
    {
34
        return new static(sprintf(
35
            'Expected a key of type integer or string. Got: %s',
36
            is_object($key) ? get_class($key) : gettype($key)
37
        ), 0, $cause);
38
    }
39
}
40