Completed
Push — master ( 8c9478...0f7d17 )
by Adam
02:25
created

VOObject::getType()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 4
ccs 0
cts 2
cp 0
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 0
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 2
    public function __construct($value)
25
    {
26 2
        if (! is_object($value)) {
27 1
            throw new InvalidTypeException($value, ['object']);
28
        }
29
30 2
        $this->reflection = new \ReflectionClass($value);
31 2
        parent::__construct($value);
32 2
    }
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 1
    public function getShortName()
46
    {
47 1
        return $this->reflection->getShortName();
48
    }
49
}
50