Passed
Push — develop ( c8d7ff...6557e2 )
by Jens
04:24
created

renderDocumentBreadcrumb()   B

Complexity

Conditions 6
Paths 8

Size

Total Lines 26
Code Lines 24

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 6
eloc 24
c 1
b 0
f 0
nc 8
nop 1
dl 0
loc 26
rs 8.439
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
        $parentPath = substr($path, 0, strrpos( $path, '/'));
0 ignored issues
show
Unused Code introduced by
The assignment to $parentPath is dead and can be removed.
Loading history...
14
        if ($path !== '/' && substr_count($path, '/') === 1) {
15
            $parentPath = '/';
16
        }
17
        ?>
18
        <a href="?path=/">
19
            Documents
20
        </a>
21
        <?php foreach ($pathParts as $part) : ?>
22
            <?php if (!empty($part)) : ?>
23
                <?php $pathPartsReconstruction .= (substr($pathPartsReconstruction, -1) === '/' ? '' : '/') . $part ?>
24
                &raquo;
25
                <a href="?path=<?= $pathPartsReconstruction ?>">
26
                    <?= $part ?>
27
                </a>
28
            <?php endif ?>
29
        <?php endforeach ?>
30
    </th>
31
    <?php
32
}
33
34
?>