Completed
Pull Request — master (#10)
by
unknown
03:05
created

PreconditionCheckerAspect   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 25
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Test Coverage

Coverage 50%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 2
c 1
b 0
f 0
lcom 1
cbo 1
dl 0
loc 25
ccs 3
cts 6
cp 0.5
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A preConditionContract() 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\PreconditionContract;
17
use PhpDeal\Exception\ContractViolation;
18
use Go\Lang\Annotation\Before;
19
20
class PreconditionCheckerAspect implements Aspect
21
{
22
    /**
23
     * @var PreconditionContract
24
     */
25
    private $contractChecker;
26
27
    public function __construct(Reader $reader)
28
    {
29
        $this->contractChecker = new PreconditionContract($reader);
30
    }
31
32
    /**
33
     * Verifies pre-condition contract for the method
34
     *
35
     * @param MethodInvocation $invocation
36
     * @Before("@execution(PhpDeal\Annotation\Verify)")
37
     *
38
     * @throws ContractViolation
39
     */
40 19
    public function preConditionContract(MethodInvocation $invocation)
41
    {
42 19
        $this->contractChecker->check($invocation);
43 6
    }
44
}
45