KeyIsNotDefinedException   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 34
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

Changes 1
Bugs 0 Features 1
Metric Value
wmc 4
c 1
b 0
f 1
lcom 1
cbo 1
dl 0
loc 34
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 9 1
A getKey() 0 4 1
A getKeyAsString() 0 4 2
1
<?php
2
3
namespace Oqq\Minc\Common\Collection\Exception;
4
5
use Oqq\Minc\Common\Exception\OutOfBoundsException;
6
7
/**
8
 * @author Eric Braun <[email protected]>
9
 */
10
class KeyIsNotDefinedException extends OutOfBoundsException
11
{
12
    /** @var mixed */
13
    protected $key;
14
15
    /**
16
     * @param mixed $key
17
     */
18
    public function __construct($key)
19
    {
20
        $this->key = $key;
21
22
        parent::__construct(sprintf(
23
            'Key with value %s is not defined',
24
            $this->getKeyAsString()
25
        ));
26
    }
27
28
    /**
29
     * @return mixed
30
     */
31
    public function getKey()
32
    {
33
        return $this->key;
34
    }
35
36
    /**
37
     * @return string
38
     */
39
    protected function getKeyAsString()
40
    {
41
        return is_string($this->key) ? '"'.$this->key.'"' : var_export($this->key, true);
42
    }
43
}
44