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

VOObject::__construct()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 9
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 6
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 9
ccs 6
cts 6
cp 1
rs 9.6666
c 0
b 0
f 0
cc 2
eloc 5
nc 2
nop 1
crap 2
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