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

RefreshInterceptor   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 20
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 3

Importance

Changes 0
Metric Value
wmc 3
c 0
b 0
f 0
lcom 1
cbo 3
dl 0
loc 20
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A invoke() 0 10 2
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