Passed
Push — master ( b2175e...d070b7 )
by Julius
02:17
created

MainIndexBuilder::render()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 15
Code Lines 13

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 2
eloc 13
nc 2
nop 0
dl 0
loc 15
rs 9.4285
c 0
b 0
f 0
1
<?php
2
/**
3
 * Created by PhpStorm.
4
 * User: jus
5
 * Date: 06.10.17
6
 * Time: 03:05
7
 */
8
9
namespace JuliusHaertl\PHPDocToRst\Builder;
10
11
12
use phpDocumentor\Reflection\Php\Class_;
13
use phpDocumentor\Reflection\Php\Namespace_;
14
15
class MainIndexBuilder extends RstBuilder {
16
17
    /** @var Namespace_[] */
18
    private $namespaces;
19
20
    public function __construct($namespaces) {
21
        $this->namespaces = $namespaces;
22
    }
23
24
    public function render() {
25
        $label = 'root-namespace';
0 ignored issues
show
Unused Code introduced by
The assignment to $label is dead and can be removed.
Loading history...
26
        $this->addLine('.. _namespace-all');
27
        $this->addH1(RstBuilder::escape('Namespaces'));
28
        $this->addLine();
29
        $this->addLine('.. toctree::');
30
        $this->addIndentLine(1, ':maxdepth: 1')->addLine();
31
        foreach ($this->namespaces as $namespace) {
32
            $namespaceString = (string)$namespace->getFqsen();
33
            $subPath = $namespaceString;
34
            $path = substr(str_replace("\\", "/", $subPath), 1) . '/index';
35
            $this->addIndentLine(1, $namespace->getFqsen() . ' <' . $path . '>');
36
        }
37
        $this->addLine();
38
        $this->addLine();
39
40
    }
41
}