Total Complexity | 3 |
Total Lines | 44 |
Duplicated Lines | 0 % |
Changes | 2 | ||
Bugs | 0 | Features | 1 |
1 | <?php |
||
11 | final class Spy |
||
12 | { |
||
13 | /** |
||
14 | * @var array |
||
15 | */ |
||
16 | private $logs = []; |
||
17 | |||
18 | public function proceed(MethodInvocation $invocation) |
||
19 | { |
||
20 | $t = microtime(true); |
||
21 | $result = $invocation->proceed(); |
||
22 | $time = microtime(true) - $t; |
||
23 | $spyLog = new SpyLog; |
||
24 | list( |
||
25 | $spyLog->class, |
||
26 | $spyLog->method, |
||
27 | $spyLog->arguments, |
||
28 | $spyLog->result, |
||
29 | $spyLog->time |
||
30 | ) = [ |
||
31 | (new \ReflectionClass($invocation->getThis()))->getParentClass()->getName(), |
||
32 | $invocation->getMethod()->getName(), |
||
33 | $invocation->getArguments()->getArrayCopy(), |
||
34 | $result, |
||
35 | $time |
||
36 | ]; |
||
37 | $this->logs[$spyLog->class][$spyLog->method][] = $spyLog; |
||
38 | |||
39 | return $result; |
||
40 | } |
||
41 | |||
42 | /** |
||
43 | * @param string $class |
||
44 | * @param string $name |
||
45 | * |
||
46 | * @return SpyLog[] |
||
47 | */ |
||
48 | public function getLogs($class, $name) |
||
55 | } |
||
56 | } |
||
57 |