Completed
Push — 2.0-dev ( 1c6990...5642d2 )
by Takehiro
09:57
created

TestMock   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 30
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0
Metric Value
wmc 4
lcom 0
cbo 0
dl 0
loc 30
rs 10
1
<?php
2
3
class TestMock
4
{
5
    private $target;
6
7
    private function __construct($target)
8
    {
9
        $this->target = $target;
10
    }
11
12
    public static function on($target)
13
    {
14
        return new self($target);
15
    }
16
17
    public function __call($name, $args)
18
    {
19
        $method = new  ReflectionMethod($this->target, $name);
20
        $method->setAccessible(true);
21
22
        return $method->invokeArgs($this->target, $args);
23
    }
24
25
    public function __get($name)
26
    {
27
        $method = new  ReflectionProperty($this->target, $name);
28
        $method->setAccessible(true);
29
30
        return $method->getValue($this->target);
31
    }
32
}
33
34