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

postConditionContract()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

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