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

PreconditionCheckerAspect::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

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