KeyNotExists   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 29
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 6 1
A getKey() 0 4 1
1
<?php namespace nyx\core\collections\exceptions;
2
3
// Internal dependencies
4
use nyx\core\collections;
5
6
/**
7
 * Key Does Not Exist In Collection Exception
8
 *
9
 * @version     0.1.0
10
 * @author      Michal Chojnacki <[email protected]>
11
 * @copyright   2012-2017 Nyx Dev Team
12
 * @link        https://github.com/unyx/nyx
13
 */
14
class KeyNotExists extends collections\Exception
15
{
16
    /**
17
     * @var mixed   The key that was not found.
18
     */
19
    private $key;
20
21
    /**
22
     * {@inheritdoc}
23
     *
24
     * @param   mixed   $key    The key that was not found.
25
     */
26
    public function __construct(collections\interfaces\Collection $collection, $key, string $message = null, $code = 0, $previous = null)
27
    {
28
        $this->key = $key;
29
30
        parent::__construct($collection, $message ?? "No item with this key [$key] exists in the Collection.", $code, $previous);
31
    }
32
33
    /**
34
     * Returns the key that was not found.
35
     *
36
     * @return  mixed
37
     */
38
    public function getKey()
39
    {
40
        return $this->key;
41
    }
42
}
43