Back   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 19
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Importance

Changes 0
Metric Value
dl 0
loc 19
rs 10
c 0
b 0
f 0
wmc 2
lcom 0
cbo 1

1 Method

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 14 2
1
<?php
2
3
namespace dokuwiki\Menu\Item;
4
5
/**
6
 * Class Back
7
 *
8
 * Navigates back up one namepspace. This is currently not used in any menu. Templates
9
 * would need to add this item manually.
10
 */
11
class Back extends AbstractItem {
12
13
    /** @inheritdoc */
14
    public function __construct() {
15
        global $ID;
16
        parent::__construct();
17
18
        $parent = tpl_getparent($ID);
19
        if(!$parent) {
0 ignored issues
show
Bug Best Practice introduced by
The expression $parent of type false|string is loosely compared to false; this is ambiguous if the string can be empty. You might want to explicitly use === false instead.

In PHP, under loose comparison (like ==, or !=, or switch conditions), values of different types might be equal.

For string values, the empty string '' is a special case, in particular the following results might be unexpected:

''   == false // true
''   == null  // true
'ab' == false // false
'ab' == null  // false

// It is often better to use strict comparison
'' === false // false
'' === null  // false
Loading history...
20
            throw new \RuntimeException("No parent for back action");
21
        }
22
23
        $this->id = $parent;
24
        $this->params = array('do' => '');
25
        $this->accesskey = 'b';
26
        $this->svg = DOKU_INC . 'lib/images/menu/12-back_arrow-left.svg';
27
    }
28
29
}
30