NavigationListElements()   F
last analyzed

Complexity

Conditions 17
Paths 384

Size

Total Lines 40
Code Lines 35

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 17
eloc 35
nc 384
nop 3
dl 0
loc 40
rs 2.0833
c 0
b 0
f 0

How to fix   Complexity   

Long Method

Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.

For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.

Commonly applied refactorings include:

1
<div id="app-navigation-files" role="navigation"></div>
2
<div class="hidden">
3
	<ul class="with-icon" tabindex="0">
4
		<?php
5
			$pinned = 0;
6
			foreach ($_['navigationItems'] as $item) {
7
				$pinned = NavigationListElements($item, $l, $pinned);
8
			}
9
		?>
10
	</ul>
11
</div>
12
13
14
<?php
15
16
/**
17
 * Prints the HTML for a single Entry.
18
 *
19
 * @param $item The item to be added
0 ignored issues
show
Bug introduced by
The type The was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
20
 * @param $l Translator
0 ignored issues
show
Bug introduced by
The type Translator was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
21
 * @param $pinned IntegerValue to count the pinned entries at the bottom
0 ignored issues
show
Bug introduced by
The type IntegerValue was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
22
 *
23
 * @return int Returns the pinned value
24
 */
25
function NavigationListElements($item, $l, $pinned) {
26
	strpos($item['classes'] ?? '', 'pinned') !== false ? $pinned++ : ''; ?>
27
	<li
28
		data-id="<?php p($item['id']) ?>"
29
		<?php if (isset($item['dir'])) { ?> data-dir="<?php p($item['dir']); ?>" <?php } ?>
30
		<?php if (isset($item['view'])) { ?> data-view="<?php p($item['view']); ?>" <?php } ?>
31
		<?php if (isset($item['expandedState'])) { ?> data-expandedstate="<?php p($item['expandedState']); ?>" <?php } ?>
32
		class="nav-<?php p($item['id']) ?>
33
		<?php if (isset($item['classes'])) {
34
		p($item['classes']);
35
	} ?>
36
		<?php p($pinned === 1 ? 'first-pinned' : '') ?>
37
		<?php if (isset($item['defaultExpandedState']) && $item['defaultExpandedState']) { ?> open<?php } ?>"
38
		<?php if (isset($item['folderPosition'])) { ?> folderposition="<?php p($item['folderPosition']); ?>" <?php } ?>>
39
40
		<a href="<?php p(isset($item['href']) ? $item['href'] : '#') ?>"
41
		   class="nav-icon-<?php p(isset($item['icon']) && $item['icon'] !== '' ? $item['icon'] : $item['id']) ?> svg"><?php p($item['name']); ?></a>
42
43
44
		<?php
45
		NavigationElementMenu($item);
46
	if (isset($item['sublist'])) {
47
		?>
48
			<button class="collapse app-navigation-noclose" aria-expanded="<?= !empty($item['defaultExpandedState']) ? 'true' : 'false' ?>"
49
				aria-label="<?php p($l->t('Toggle %1$s sublist', $item['name'])) ?>"
50
				<?php if (sizeof($item['sublist']) == 0) { ?> style="display: none" <?php } ?>>
51
			</button>
52
			<ul id="sublist-<?php p($item['id']); ?>">
53
				<?php
54
				foreach ($item['sublist'] as $item) {
0 ignored issues
show
introduced by
$item is overwriting one of the parameters of this function.
Loading history...
55
					$pinned = NavigationListElements($item, $l, $pinned);
56
				} ?>
57
			</ul>
58
		<?php
59
	} ?>
60
	</li>
61
62
63
	<?php
64
	return $pinned;
65
}
66
67
/**
68
 * Prints the HTML for a dotmenu.
69
 *
70
 * @param $item The item to be added
71
 *
72
 * @return void
73
 */
74
function NavigationElementMenu($item) {
75
	if (isset($item['menubuttons']) && $item['menubuttons'] === 'true') {
76
		?>
77
		<div id="dotmenu-<?php p($item['id']); ?>"
78
			 class="app-navigation-entry-utils" <?php if (isset($item['enableMenuButton']) && $item['enableMenuButton'] === 0) { ?> style="display: none"<?php } ?>>
79
			<ul>
80
				<li class="app-navigation-entry-utils-menu-button svg">
81
					<button id="dotmenu-button-<?php p($item['id']) ?>"></button>
82
				</li>
83
			</ul>
84
		</div>
85
		<div id="dotmenu-content-<?php p($item['id']) ?>"
86
			 class="app-navigation-entry-menu">
87
			<ul>
88
89
			</ul>
90
		</div>
91
	<?php
92
	}
93
}
94