Completed
Push — master ( a4e176...8c9478 )
by Adam
02:50
created

VOObject   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 38
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Test Coverage

Coverage 60%

Importance

Changes 0
Metric Value
wmc 4
lcom 1
cbo 2
dl 0
loc 38
ccs 6
cts 10
cp 0.6
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 9 2
A getType() 0 4 1
A getShortName() 0 4 1
1
<?php
2
3
namespace BestServedCold\PhalueObjects;
4
5
use BestServedCold\PhalueObjects\Exception\InvalidTypeException;
6
7
/**
8
 * Class VOObject
9
 *
10
 * @package BestServedCold\PhalueObjects\ValueObject
11
 */
12
class VOObject extends ValueObject
13
{
14
    /**
15
     * @var \ReflectionClass
16
     */
17
    protected $reflection;
18
19
    /**
20
     * ObjectValueObject constructor.
21
     *
22
     * @param $value
23
     */
24 1
    public function __construct($value)
25
    {
26 1
        if (! is_object($value)) {
27 1
            throw new InvalidTypeException($value, ['object']);
28
        }
29
30 1
        $this->reflection = new \ReflectionClass($this);
31 1
        parent::__construct($value);
32 1
    }
33
34
    /**
35
     * @return string
36
     */
37
    public function getType()
38
    {
39
        return get_class($this->getValue());
40
    }
41
42
    /**
43
     * @return string
44
     */
45
    public function getShortName()
46
    {
47
        return $this->reflection->getShortName();
48
    }
49
}
50