Completed
Push — master ( c432ac...8e117f )
by Mathijs
04:01
created

BaseObject   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 31
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Importance

Changes 0
Metric Value
wmc 5
lcom 0
cbo 1
dl 0
loc 31
rs 10
c 0
b 0
f 0

4 Methods

Rating   Name   Duplication   Size   Complexity  
A getValue() 0 4 1
A __construct() 0 8 2
A validate() 0 3 1
A __toString() 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
    public function getValue() : string
15
    {
16
        return $this->value;
17
    }
18
19
20
    protected function __construct(String $value)
21
    {
22
        $this->value = $value;
23
24
        if (!$this->validate($this->value)) {
25
            throw new InvalidDataException("", $this->value);
26
        }
27
    }
28
29
    protected function validate($value) : bool {
30
        return true;
31
    }
32
33
    public function __toString() : string
34
    {
35
        return $this->value;
36
    }
37
}
38