Completed
Push — develop ( 9193e7...62056c )
by Jaap
12:45 queued 02:43
created

InterfaceTreeBuilder::execute()   B

Complexity

Conditions 5
Paths 5

Size

Total Lines 14
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 5
eloc 7
nc 5
nop 1
dl 0
loc 14
rs 8.8571
c 0
b 0
f 0
1
<?php
2
/**
3
 * This file is part of phpDocumentor.
4
 *
5
 *  For the full copyright and license information, please view the LICENSE
6
 *  file that was distributed with this source code.
7
 *
8
 *  @copyright 2010-2017 Mike van Riel<[email protected]>
9
 *  @license   http://www.opensource.org/licenses/mit-license.php MIT
10
 *  @link      http://phpdoc.org
11
 */
12
13
namespace phpDocumentor\Compiler\Pass;
14
15
use phpDocumentor\Compiler\CompilerPassInterface;
16
use phpDocumentor\Descriptor\ClassDescriptor;
17
use phpDocumentor\Descriptor\InterfaceDescriptor;
18
use phpDocumentor\Descriptor\ProjectDescriptor;
19
use phpDocumentor\Reflection\Fqsen;
20
21
final class InterfaceTreeBuilder implements CompilerPassInterface
22
{
23
    const COMPILER_PRIORITY = 9000;
24
25
    /**
26
     * Returns a textual description of what this pass does for output purposes.
27
     *
28
     * Please note that the command line will be truncated to 68 characters (<message> .. 000.000s) so longer
29
     * descriptions won't have much use.
30
     *
31
     * @return string
32
     */
33
    public function getDescription()
34
    {
35
        return "Adding Parents to child interfaces";
36
    }
37
38
    /**
39
     * Executes a compiler pass.
40
     *
41
     * This method will execute the business logic associated with a given compiler pass and allow it to manipulate
42
     * or consumer the Object Graph using the ProjectDescriptor object.
43
     *
44
     * @param ProjectDescriptor $project Representation of the Object Graph that can be manipulated.
45
     *
46
     * @return mixed
47
     */
48
    public function execute(ProjectDescriptor $project)
49
    {
50
        foreach ($project->getFiles() as $file) {
51
            /** @var InterfaceDescriptor $interface */
52
            foreach ($file->getInterfaces()->getAll() as $interface) {
53
                foreach ($interface->getParent()->getAll() as $parentName) {
54
                    $parent = $project->getIndexes()->get('interfaces')->get((string)$parentName);
55
                    if ($parent instanceof InterfaceDescriptor) {
56
                        $interface->getParent()->set((string)$parentName, $parent);
57
                    }
58
                }
59
            }
60
        }
61
    }
62
}
63