IndexPage::getTarget()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 11
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 6
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 11
ccs 6
cts 6
cp 1
rs 9.4285
cc 1
eloc 7
nc 1
nop 0
crap 1
1
<?php
2
namespace Bookdown\Bookdown\Content;
3
4
use Bookdown\Bookdown\Config\IndexConfig;
5
6
class IndexPage extends Page
7
{
8
    protected $children;
9
10
    protected $tocEntries;
11
12
    protected $config;
13
14 22
    public function __construct(
15
        IndexConfig $config,
16
        $name,
17
        IndexPage $parent,
18
        $count
19
    ) {
20 22
        $this->config = $config;
21 22
        $this->name = $name;
22 22
        $this->parent = $parent;
23 22
        $this->count = $count;
24 22
        $this->setTitle($config->getTitle());
25 22
    }
26
27 21
    public function getConfig()
28
    {
29 21
        return $this->config;
30
    }
31
32 16
    public function getHref()
33
    {
34 16
        $base = $this->getParent()->getHref();
35 16
        return $base . $this->getName() . '/';
36
    }
37
38 22
    public function addChild(Page $child)
39
    {
40 22
        $this->children[] = $child;
41 22
    }
42
43 13
    public function getChildren()
44
    {
45 13
        return $this->children;
46
    }
47
48 19
    public function getTarget()
49
    {
50 19
        $base = rtrim(
51 19
            dirname($this->getParent()->getTarget()),
52
            DIRECTORY_SEPARATOR
53 19
        );
54
55
        return $base
56 19
            . DIRECTORY_SEPARATOR . $this->getName()
57 19
            . DIRECTORY_SEPARATOR . 'index.html';
58
    }
59
60 12
    public function setTocEntries($tocEntries)
61
    {
62 12
        $this->tocEntries = $tocEntries;
63 12
    }
64
65 5
    public function hasTocEntries()
66
    {
67 5
        return (bool) $this->tocEntries;
68
    }
69
70 12
    public function getTocEntries()
71
    {
72 12
        return $this->tocEntries;
73
    }
74
75 15
    public function isIndex()
76
    {
77 15
        return true;
78
    }
79
}
80