Completed
Pull Request — 1.x (#279)
by Alexander
02:23
created

NotPointcut::getKind()   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 0
crap 1
1
<?php
2
/*
3
 * Go! AOP framework
4
 *
5
 * @copyright Copyright 2013, 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 Go\Aop\Pointcut;
12
13
use Go\Aop\Pointcut;
14
15
/**
16
 * Signature method pointcut checks method signature (modifiers and name) to match it
17
 */
18
class NotPointcut implements Pointcut
19
{
20
    use PointcutClassFilterTrait;
21
22
    /**
23
     * @var Pointcut
24
     */
25
    protected $pointcut;
26
27
    /**
28
     * Kind of pointcut
29
     *
30
     * @var int
31
     */
32
    protected $kind = 0;
33
34
    /**
35
     * Inverse pointcut matcher
36
     *
37
     * @param Pointcut $pointcut Pointcut expression
38
     */
39 2
    public function __construct(Pointcut $pointcut)
40
    {
41 2
        $this->pointcut = $pointcut;
42 2
        $this->kind     = $pointcut->getKind();
43 2
    }
44
45
    /**
46
     * Performs matching of point of code
47
     *
48
     * @param mixed $point Specific part of code, can be any Reflection class
49
     * @param null|mixed $context Related context, can be class or namespace
50
     * @param null|string|object $instance Invocation instance or string for static calls
51
     * @param null|array $arguments Dynamic arguments for method
52
     *
53
     * @return bool
54
     */
55
    public function matches($point, $context = null, $instance = null, array $arguments = null)
56
    {
57
        $isMatchesPre = $this->pointcut->getClassFilter()->matches($context);
58
        if (!$isMatchesPre) {
59
            return true;
60
        }
61
        $isMatchesPoint = $this->pointcut->matches($point, $context, $instance, $arguments);
62
        if (!$isMatchesPoint) {
63
            return true;
64
        }
65
66
        return false;
67
    }
68
69
    /**
70
     * Returns the kind of point filter
71
     *
72
     * @return integer
73
     */
74 1
    public function getKind()
75
    {
76 1
        return $this->kind;
77
    }
78
}
79