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

QueryRepositoryAopModule   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 32
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 2
c 1
b 0
f 0
lcom 1
cbo 2
dl 0
loc 32
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
B configure() 0 26 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\RepositoryModule\Annotation\Cacheable;
10
use BEAR\RepositoryModule\Annotation\Purge;
11
use BEAR\RepositoryModule\Annotation\Refresh;
12
use Ray\Di\AbstractModule;
13
14
class QueryRepositoryAopModule extends AbstractModule
15
{
16
    /**
17
     * {@inheritdoc}
18
     */
19
    protected function configure()
20
    {
21
        // @Cacheable
22
        $this->bindPriorityInterceptor(
23
            $this->matcher->annotatedWith(Cacheable::class),
24
            $this->matcher->startsWith('onGet'),
25
            [CacheInterceptor::class]
26
        );
27
        foreach (['onPost', 'onPut', 'onPatch', 'onDelete'] as $starts) {
28
            $this->bindInterceptor(
29
                $this->matcher->annotatedWith(Cacheable::class),
30
                $this->matcher->startsWith($starts),
31
                [CommandInterceptor::class]
32
            );
33
            $this->bindInterceptor(
34
                $this->matcher->logicalNot(
35
                    $this->matcher->annotatedWith(Cacheable::class)
36
                ),
37
                $this->matcher->logicalOr(
38
                    $this->matcher->annotatedWith(Purge::class),
39
                    $this->matcher->annotatedWith(Refresh::class)
40
                ),
41
                [RefreshInterceptor::class]
42
            );
43
        }
44
    }
45
}
46