Passed
Branch add-cache (e7677a)
by Michael
02:58 queued 36s
created

KeyConflictException   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 47
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
wmc 2
c 0
b 0
f 0
lcom 0
cbo 0
dl 0
loc 47
ccs 0
cts 14
cp 0
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 8 1
A __toString() 0 20 1
1
<?php
2
3
namespace micmania1\config\Exceptions;
4
5
use Exception;
6
7
class KeyConflictException extends Exception
8
{
9
    /**
10
     * @var string
11
     */
12
    protected $key;
13
14
    /**
15
     * @var array
16
     */
17
    protected $mine;
18
19
    /**
20
     * @var array
21
     */
22
    protected $theirs;
23
24
    public function __construct($key, $mine, $theirs)
25
    {
26
        $this->key = $key;
27
        $this->mine = $mine;
28
        $this->theirs = $theirs;
29
30
        parent::__construct($this->__toString());
31
    }
32
33
    public function __toString()
34
    {
35
        $error = <<<'ERROR'
36
Key clash on key '%s'.
37
38
Mine:
39
%s
40
41
Thiers:
42
%s
43
44
ERROR;
45
46
        return sprintf(
47
            $error,
48
            $this->key,
49
            print_r($this->mine, true),
50
            print_r($this->theirs, true)
51
        );
52
    }
53
}
54