InterfaceExtractor   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 44
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2
Metric Value
wmc 3
lcom 1
cbo 2
dl 0
loc 44
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A extract() 0 5 1
A setNamespace() 0 4 1
1
<?php
2
3
/*
4
 * (c) Jean-François Lépine <https://twitter.com/Halleck45>
5
 *
6
 * For the full copyright and license information, please view the LICENSE
7
 * file that was distributed with this source code.
8
 */
9
10
namespace Hal\Component\OOP\Extractor;
11
use Hal\Component\OOP\Reflected\ReflectedInterface;
12
use Hal\Component\Token\TokenCollection;
13
14
15
/**
16
 * @author Jean-François Lépine <https://twitter.com/Halleck45>
17
 */
18
class InterfaceExtractor implements ExtractorInterface {
19
20
    /**
21
     * @var Searcher
22
     */
23
    private $searcher;
24
25
    /**
26
     * @var string
27
     */
28
    private $namespace;
29
30
    /**
31
     * Constructor
32
     *
33
     * @param Searcher $searcher
34
     */
35
    public function __construct(Searcher $searcher)
36
    {
37
        $this->searcher = $searcher;
38
    }
39
40
    /**
41
     * Extract class from position
42
     *
43
     * @param $n
44
     * @param TokenCollection $tokens
45
     * @return ReflectedInterface
46
     */
47
    public function extract(&$n, TokenCollection $tokens)
48
    {
49
        $classname = $this->searcher->getFollowingName($n, $tokens);
50
        return new ReflectedInterface($this->namespace, trim($classname));
51
    }
52
53
    /**
54
     * @param string $namespace
55
     */
56
    public function setNamespace($namespace)
57
    {
58
        $this->namespace = (string) $namespace;
59
    }
60
61
};