Completed
Push — 1.x ( c183a4...05b51a )
by Alexander
8s
created

NamespacedReflectionFunction   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 33
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Test Coverage

Coverage 0%
Metric Value
wmc 3
lcom 1
cbo 0
dl 0
loc 33
ccs 0
cts 12
cp 0
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 5 1
A getNamespaceName() 0 8 2
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\Support;
12
13
use ReflectionFunction;
14
15
/**
16
 * Namespaced version of global functions
17
 */
18
class NamespacedReflectionFunction extends ReflectionFunction
19
{
20
    /**
21
     * Custom namespace name
22
     *
23
     * @var string
24
     */
25
    private $namespace = '';
26
27
    /**
28
     * Extends the logic with passing the namespace name
29
     *
30
     * @param string $namespace Name of the namespace
31
     * {@inheritDoc}
32
     */
33
    public function __construct($name, $namespace = '')
34
    {
35
        $this->namespace = $namespace;
36
        parent::__construct($name);
37
    }
38
39
    /**
40
     * {@inheritDoc}
41
     */
42
    public function getNamespaceName()
43
    {
44
        if ($this->namespace) {
45
            return $this->namespace;
46
        }
47
48
        return parent::getNamespaceName();
49
    }
50
}
51