Completed
Push — 1.x ( bee4c5...6aacf6 )
by Akihito
13s queued 10s
created

QueryRepositoryAopModule::configure()   B

Complexity

Conditions 2
Paths 2

Size

Total Lines 26
Code Lines 17

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 10
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 26
ccs 10
cts 10
cp 1
rs 8.8571
cc 2
eloc 17
nc 2
nop 0
crap 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