Completed
Pull Request — 1.x (#49)
by Akihito
05:32 queued 03:43
created

QueryRepositoryAopModule   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 32
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Test Coverage

Coverage 100%

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
ccs 11
cts 11
cp 1
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 15
     * {@inheritdoc}
18
     */
19
    protected function configure()
20 15
    {
21 15
        // @Cacheable
22 15
        $this->bindPriorityInterceptor(
23 15
            $this->matcher->annotatedWith(Cacheable::class),
24
            $this->matcher->startsWith('onGet'),
25 15
            [CacheInterceptor::class]
26 15
        );
27 15
        foreach (['onPost', 'onPut', 'onPatch', 'onDelete'] as $starts) {
28 15
            $this->bindInterceptor(
29 15
                $this->matcher->annotatedWith(Cacheable::class),
30
                $this->matcher->startsWith($starts),
31
                [CommandInterceptor::class]
32 15
            );
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