Passed
Push — master ( 354cb3...72815c )
by Jens
03:33
created

renderDocumentBreadcrumb()   B

Complexity

Conditions 4
Paths 4

Size

Total Lines 22
Code Lines 21

Duplication

Lines 0
Ratio 0 %

Importance

Changes 2
Bugs 0 Features 0
Metric Value
cc 4
eloc 21
c 2
b 0
f 0
nc 4
nop 1
dl 0
loc 22
rs 8.9197
1
<?php
2
/**
3
 * @param string $path
4
 */
5
function renderDocumentBreadcrumb($path)
6
{
7
    ?>
8
    <th colspan="4">
9
        <?php
10
        $pathParts = explode('/', $path);
11
        array_shift($pathParts);
12
        $pathPartsReconstruction = '';
13
        ?>
14
        <a href="?path=/">
15
            Documents
16
        </a>
17
        <?php foreach ($pathParts as $part) : ?>
18
            <?php if (!empty($part)) : ?>
19
                <?php $pathPartsReconstruction .= (substr($pathPartsReconstruction, -1) === '/' ? '' : '/') . $part ?>
20
                &raquo;
21
                <a href="?path=<?= $pathPartsReconstruction ?>">
22
                    <?= $part ?>
23
                </a>
24
            <?php endif ?>
25
        <?php endforeach ?>
26
    </th>
27
    <?php
28
}
29
30
?>