ClassFileBuilder::addImplementedInterfaces()   A
last analyzed

Complexity

Conditions 3
Paths 4

Size

Total Lines 8
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 2
Bugs 2 Features 0
Metric Value
cc 3
eloc 5
c 2
b 2
f 0
nc 4
nop 1
dl 0
loc 8
rs 10
1
<?php
2
/**
3
 * @copyright Copyright (c) 2017 Julius Härtl <[email protected]>
4
 * @author    Julius Härtl <[email protected]>
5
 * @license   GNU AGPL version 3 or any later version
6
 *
7
 *  This program is free software: you can redistribute it and/or modify
8
 *  it under the terms of the GNU Affero General Public License as
9
 *  published by the Free Software Foundation, either version 3 of the
10
 *  License, or (at your option) any later version.
11
 *
12
 *  This program is distributed in the hope that it will be useful,
13
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
14
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15
 *  GNU Affero General Public License for more details.
16
 *
17
 *  You should have received a copy of the GNU Affero General Public License
18
 *  along with this program. If not, see <http://www.gnu.org/licenses/>.
19
 */
20
21
namespace JuliusHaertl\PHPDocToRst\Builder;
22
23
use phpDocumentor\Reflection\DocBlock\Tags\Param;
24
use phpDocumentor\Reflection\Php\Class_;
25
26
class ClassFileBuilder extends FileBuilder
27
{
28
    protected function render()
29
    {
30
31
        /** @var Class_ $class */
32
        $class = $this->element;
33
34
        if (!$this->shouldRenderElement($class)) {
35
            return;
36
        }
37
        $this->addPageHeader($class);
38
39
        $this->indent();
40
        $this->addDocBlockDescription($class);
41
        $this->addParent($class);
42
        $this->addImplementedInterfaces($class);
43
        $this->addUsedTraits($class);
44
        $this->unindent();
45
46
        $this->addAfterIntroduction($class);
47
48
        $this->addConstants($class->getConstants());
49
        $this->addProperties($class->getProperties());
50
51
        $this->addMethods($class->getMethods());
52
    }
53
54
    /**
55
     * @param Class_ $element
56
     */
57
    protected function addImplementedInterfaces($element)
58
    {
59
        $implementedInterfaces = '';
60
        foreach ($element->getInterfaces() as $int) {
61
            $implementedInterfaces .= $this->getLink('interface', $int).' ';
62
        }
63
        if ($implementedInterfaces !== '') {
64
            $this->addFieldList('Implements', $implementedInterfaces);
65
        }
66
    }
67
}
68