1 | <?php |
||
21 | class PreconditionCheckerAspect extends AbstractContractAspect implements Aspect |
||
22 | { |
||
23 | /** |
||
24 | * @var MethodConditionWithInheritDocFetcher |
||
25 | */ |
||
26 | private $methodConditionFetcher; |
||
27 | |||
28 | public function __construct(Reader $reader) |
||
33 | |||
34 | /** |
||
35 | * Verifies pre-condition contract for the method |
||
36 | * |
||
37 | * @param MethodInvocation $invocation |
||
38 | * @Before("@execution(PhpDeal\Annotation\Verify)") |
||
39 | * |
||
40 | * @throws ContractViolation |
||
41 | */ |
||
42 | 26 | public function preConditionContract(MethodInvocation $invocation) |
|
43 | { |
||
44 | 26 | $object = $invocation->getThis(); |
|
45 | 26 | $args = $this->fetchMethodArguments($invocation); |
|
46 | 26 | $scope = $invocation->getMethod()->getDeclaringClass()->name; |
|
47 | |||
48 | 26 | $allContracts = $this->fetchAllContracts($invocation); |
|
49 | 26 | $this->ensureContracts($invocation, $allContracts, $object, $scope, $args); |
|
50 | 9 | } |
|
51 | |||
52 | /** |
||
53 | * @param MethodInvocation $invocation |
||
54 | * @return array |
||
55 | */ |
||
56 | 26 | private function fetchAllContracts(MethodInvocation $invocation) |
|
68 | |||
69 | /** |
||
70 | * @param MethodInvocation $invocation |
||
71 | * @return array |
||
72 | */ |
||
73 | 26 | private function fetchParentsContracts(MethodInvocation $invocation) |
|
80 | } |
||
81 |