BaseObject   A
last analyzed

Complexity

Total Complexity 6

Size/Duplication

Total Lines 36
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 6
lcom 0
cbo 1
dl 0
loc 36
ccs 13
cts 13
cp 1
rs 10
c 0
b 0
f 0

5 Methods

Rating   Name   Duplication   Size   Complexity  
A validate() 0 3 1
A getValue() 0 4 1
A __toString() 0 4 1
A __construct() 0 8 2
A __toInt() 0 4 1
1
<?php
2
3
namespace mcorten87\rabbitmq_api\objects;
4
5
use mcorten87\rabbitmq_api\exceptions\InvalidDataException;
6
7
class BaseObject
8
{
9
    private $value;
10
11
    /**
12
     * @return mixed
13
     */
14 83
    public function getValue() : string
15
    {
16 83
        return $this->value;
17
    }
18
19
20 160
    protected function __construct(String $value)
21
    {
22 160
        $this->value = $value;
23
24 160
        if (!$this->validate($this->value)) {
25 26
            throw new InvalidDataException();
26
        }
27 160
    }
28
29 42
    protected function validate($value) : bool {
30 42
        return true;
31
    }
32
33 67
    public function __toString() : string
34
    {
35 67
        return $this->value;
36
    }
37
38 4
    public function __toInt() : int
39
    {
40 4
        return (int)$this->value;
41
    }
42
}
43