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

NotPointcut   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 61
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 3

Test Coverage

Coverage 42.86%

Importance

Changes 3
Bugs 0 Features 0
Metric Value
wmc 5
c 3
b 0
f 0
lcom 1
cbo 3
dl 0
loc 61
ccs 6
cts 14
cp 0.4286
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 5 1
A matches() 0 13 3
A getKind() 0 4 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