Completed
Push — 1.x ( adc7c3...201c0c )
by Alexander
05:59 queued 01:58
created

AbstractGenericPointcutAdvisor::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 4
ccs 3
cts 3
cp 1
rs 10
cc 1
eloc 2
nc 1
nop 1
crap 1
1
<?php
2
/*
3
 * Go! AOP framework
4
 *
5
 * @copyright Copyright 2012, 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\Support;
12
13
use Go\Aop\Advice;
14
use Go\Aop\PointcutAdvisor;
15
16
/**
17
 * Abstract generic PointcutAdvisor that allows for any Advice to be configured.
18
 */
19
abstract class AbstractGenericPointcutAdvisor implements PointcutAdvisor
20
{
21
    /**
22
     * Instance of advice
23
     *
24
     * @var Advice
25
     */
26
    protected $advice;
27
28
    /**
29
     * Initializes an advisor with advice
30
     *
31
     * @param Advice $advice Advice to apply
32
     */
33 2
    public function __construct(Advice $advice)
34
    {
35 2
        $this->advice = $advice;
36 2
    }
37
38
    /**
39
     * Returns an advice to apply
40
     *
41
     * @return Advice|null
42
     */
43 2
    public function getAdvice()
44
    {
45 2
        return $this->advice;
46
    }
47
48
    /**
49
     * Return string representation of object
50
     *
51
     * @return string
52
     */
53
    public function __toString()
54
    {
55
        $adviceClass = get_class($this->getAdvice());
56
57
        return get_called_class() . ": advice [{$adviceClass}]";
58
    }
59
}
60