Completed
Push — refresh ( bee4c5...1d01e3 )
by Akihito
02:47
created

RefreshInterceptor::invoke()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 10
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
c 0
b 0
f 0
dl 0
loc 10
rs 9.4285
cc 2
eloc 6
nc 2
nop 1
1
<?php
2
/**
3
 * This file is part of the BEAR.QueryRepository package.
4
 *
5
 * @license http://opensource.org/licenses/MIT MIT
6
 */
7
namespace BEAR\QueryRepository;
8
9
use BEAR\QueryRepository\Exception\ReturnValueIsNotResourceObjectException;
10
use BEAR\Resource\ResourceObject;
11
use Ray\Aop\MethodInterceptor;
12
use Ray\Aop\MethodInvocation;
13
14
class RefreshInterceptor implements MethodInterceptor
15
{
16
    private $command;
17
18
    public function __construct(RefreshAnnotatedCommand $command)
19
    {
20
        $this->command = $command;
21
    }
22
23
    public function invoke(MethodInvocation $invocation)
24
    {
25
        $resourceObject = $invocation->proceed();
26
        if (! $resourceObject instanceof ResourceObject) {
27
            throw new ReturnValueIsNotResourceObjectException(\get_class($invocation->getThis()));
28
        }
29
        $this->command->command($invocation, $resourceObject);
30
31
        return $resourceObject;
32
    }
33
}
34