Completed
Push — master ( 89b65c...bde278 )
by Alexander
02:30
created

PostconditionCheckerAspect   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 26
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Test Coverage

Coverage 40%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 2
c 1
b 0
f 0
lcom 1
cbo 1
dl 0
loc 26
ccs 2
cts 5
cp 0.4
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A postConditionContract() 0 4 1
1
<?php
2
/**
3
 * PHP Deal framework
4
 *
5
 * @copyright Copyright 2014, Lisachenko Alexander <[email protected]>
6
 *
7
 * This source file is subject to the license that is bundled
8
 * with this source code in the file LICENSE.
9
 */
10
11
namespace PhpDeal\Aspect;
12
13
use Doctrine\Common\Annotations\Reader;
14
use Go\Aop\Aspect;
15
use Go\Aop\Intercept\MethodInvocation;
16
use PhpDeal\Contract\PostconditionContract;
17
use PhpDeal\Exception\ContractViolation;
18
use Go\Lang\Annotation\Around;
19
20
class PostconditionCheckerAspect implements Aspect
21
{
22
    /**
23
     * @var PostconditionContract
24
     */
25
    private $contractChecker;
26
27
    public function __construct(Reader $reader)
28
    {
29
        $this->contractChecker = new PostconditionContract($reader);
30
    }
31
32
    /**
33
     * Verifies post-condition contract for the method
34
     *
35
     * @Around("@execution(PhpDeal\Annotation\Ensure)")
36
     * @param MethodInvocation $invocation
37
     *
38
     * @throws ContractViolation
39
     * @return mixed
40
     */
41 8
    public function postConditionContract(MethodInvocation $invocation)
42
    {
43 8
        return $this->contractChecker->check($invocation);
44
    }
45
}
46