1 | <?php |
||
23 | class ContractCheckerAspect implements Aspect |
||
24 | { |
||
25 | /** |
||
26 | * Annotation reader |
||
27 | * |
||
28 | * @var Reader |
||
29 | */ |
||
30 | private $reader; |
||
31 | |||
32 | /** |
||
33 | * Default constructor |
||
34 | * |
||
35 | * @param Reader $reader Annotation reader |
||
36 | */ |
||
37 | public function __construct(Reader $reader) |
||
41 | |||
42 | /** |
||
43 | * Verifies pre-condition contract for the method |
||
44 | * |
||
45 | * @param MethodInvocation $invocation |
||
46 | * @Before("@execution(PhpDeal\Annotation\Verify)") |
||
47 | * |
||
48 | * @throws ContractViolation |
||
49 | */ |
||
50 | 19 | public function preConditionContract(MethodInvocation $invocation) |
|
54 | |||
55 | /** |
||
56 | * Verifies post-condition contract for the method |
||
57 | * |
||
58 | * @Around("@execution(PhpDeal\Annotation\Ensure)") |
||
59 | * @param MethodInvocation $invocation |
||
60 | * |
||
61 | * @throws ContractViolation |
||
62 | * @return mixed |
||
63 | */ |
||
64 | 8 | public function postConditionContract(MethodInvocation $invocation) |
|
68 | |||
69 | /** |
||
70 | * Verifies invariants for contract class |
||
71 | * |
||
72 | * @Around("@within(PhpDeal\Annotation\Invariant) && execution(public **->*(*))") |
||
73 | * @param MethodInvocation $invocation |
||
74 | * |
||
75 | * @throws ContractViolation |
||
76 | * @return mixed |
||
77 | */ |
||
78 | 7 | public function invariantContract(MethodInvocation $invocation) |
|
82 | } |
||
83 |