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

BaseObject::getValue()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 0
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