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

VOObject   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 38
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Test Coverage

Coverage 80%

Importance

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

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 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