SmartValidator   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 44
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 4
lcom 1
cbo 1
dl 0
loc 44
ccs 12
cts 12
cp 1
rs 10
c 0
b 0
f 0

4 Methods

Rating   Name   Duplication   Size   Complexity  
A getValue() 0 3 1
A setValue() 0 5 1
A __construct() 0 8 1
A getValueType() 0 3 1
1
<?php
2
3
namespace PhMap\Exception;
4
5
use \PhMap\Exception;
6
7
/**
8
 * Class SmartValidator
9
 * @package PhMap\Exception
10
 */
11
class SmartValidator extends Exception {
12
13
    /**
14
     * @var mixed
15
     */
16
    private $value;
17
18
    /**
19
     * @return mixed
20
     */
21 1
    public function getValue() {
22 1
        return $this->value;
23
    }
24
25
    /**
26
     * @param mixed $value
27
     * @return $this
28
     */
29 1
    public function setValue($value) {
30 1
        $this->value = $value;
31
32 1
        return $this;
33
    }
34
35
    /**
36
     * @param mixed $value
37
     */
38 1
    public function __construct($value) {
39 1
        $this->setValue($value);
40
41
        $message = 'Value is unsupported. Must be json string, object or array; '
42 1
            . $this->getValueType() . ' given';
43
44 1
        parent::__construct($message);
45 1
    }
46
47
    /**
48
     * @return string
49
     */
50 1
    public function getValueType() {
51 1
        return gettype($this->getValue());
52
    }
53
54
}