Panel::_hasPermission()   F
last analyzed

Complexity

Conditions 11
Paths 1024

Size

Total Lines 46

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 17
CRAP Score 11.8364

Importance

Changes 0
Metric Value
dl 0
loc 46
ccs 17
cts 21
cp 0.8095
rs 3.15
c 0
b 0
f 0
cc 11
nc 1024
nop 1
crap 11.8364

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
<?php
2
namespace Redaxscript\Admin\View\Helper;
3
4
use Redaxscript\Admin;
5
use Redaxscript\Html;
6
use Redaxscript\Module;
7
use Redaxscript\Validator;
8
use function array_key_exists;
9
use function array_replace_recursive;
10
use function count;
11
12
/**
13
 * helper class to create the admin panel
14
 *
15
 * @since 4.0.0
16
 *
17
 * @package Redaxscript
18
 * @category View
19
 * @author Henry Ruhs
20
 */
21
22
class Panel extends Admin\View\ViewAbstract
23
{
24
	/**
25
	 * options of the panel
26
	 *
27
	 * @var array
28
	 */
29
30
	protected $_optionArray =
31
	[
32
		'className' =>
33
		[
34
			'list' =>
35
			[
36
				'panel' => 'rs-admin-fn-dropdown rs-admin-list-panel',
37
				'content' => 'rs-admin-fn-content-panel rs-admin-list-panel-children',
38
				'access' => 'rs-admin-fn-content-panel rs-admin-list-panel-children',
39
				'system' => 'rs-admin-fn-content-panel rs-admin-list-panel-children',
40
				'notification' => 'rs-admin-fn-content-panel rs-admin-list-panel-children rs-admin-list-notification'
41
			],
42
			'item' =>
43
			[
44
				'content' => 'rs-admin-item-panel',
45
				'access' => 'rs-admin-item-panel',
46
				'system' => 'rs-admin-item-panel',
47
				'profile' => 'rs-admin-item-panel',
48
				'notification' => 'rs-admin-item-panel',
49
				'logout' => 'rs-admin-item-panel rs-admin-item-panel-logout'
50
			],
51
			'link' =>
52
			[
53
				'view' => 'rs-admin-link-panel rs-admin-link-panel-view',
54
				'new' => 'rs-admin-link-panel rs-admin-link-panel-new',
55
				'system' => 'rs-admin-link-panel rs-admin-link-panel-system',
56
				'profile' => 'rs-admin-link-panel rs-admin-link-panel-profile',
57
				'logout' => 'rs-admin-link-panel rs-admin-link-panel-logout'
58
			],
59
			'label' =>
60
			[
61
				'content' => 'rs-admin-fn-toggle-panel rs-admin-label-panel rs-admin-label-panel-content',
62
				'access' => 'rs-admin-fn-toggle-panel rs-admin-label-panel rs-admin-label-panel-access',
63
				'system' => 'rs-admin-fn-toggle-panel rs-admin-label-panel rs-admin-label-panel-system',
64
				'notification' => 'rs-admin-fn-toggle-panel rs-admin-label-panel rs-admin-label-panel-notification'
65
			],
66
			'note' =>
67
			[
68
				'success' => 'rs-admin-is-success',
69
				'warning' => 'rs-admin-is-warning',
70
				'error' => 'rs-admin-is-error',
71
				'info' => 'rs-admin-is-info'
72
			],
73
			'text' => 'rs-admin-text-panel-group',
74
			'input' => 'rs-admin-fn-status-panel',
75
			'sup' => 'rs-admin-sup-panel-notification'
76
		]
77
	];
78
79
	/**
80
	 * init the class
81
	 *
82
	 * @since 4.0.0
83
	 *
84
	 * @param array $optionArray options of the panel
85
	 *
86
	 * @return self
87
	 */
88 8
89
	public function init(array $optionArray = []) : self
90 8
	{
91 8
		$this->_optionArray = array_replace_recursive($this->_optionArray, $optionArray);
92
		return $this;
93
	}
94
95
	/**
96
	 * render the view
97
	 *
98
	 * @since 4.0.0
99
	 *
100
	 * @return string
101
	 */
102 8
103
	public function render() : string
104 8
	{
105 8
		$output = Module\Hook::trigger('adminPanelStart');
106
		$outputItem = null;
107
108
		/* html element */
109 8
110 8
		$listElement = new Html\Element();
111
		$listElement->init('ul',
112 8
		[
113
			'class' => $this->_optionArray['className']['list']['panel']
114
		]);
115
116
		/* collect item output */
117 8
118
		if ($this->_hasPermission('contents'))
119 2
		{
120
			$outputItem .= $this->_renderContent();
121 8
		}
122
		if ($this->_hasPermission('access'))
123 2
		{
124
			$outputItem .= $this->_renderAccess();
125 8
		}
126
		if ($this->_hasPermission('system'))
127 1
		{
128
			$outputItem .= $this->_renderSystem();
129 8
		}
130
		if ($this->_hasPermission('profile'))
131 1
		{
132
			$outputItem .= $this->_renderProfile();
133 8
		}
134
		if ($this->_hasPermission('notification'))
135 1
		{
136
			$outputItem .= $this->_renderNotification();
137 8
		}
138
		$outputItem .= $this->_renderLogout();
139
140
		/* collect output */
141 8
142 8
		if ($outputItem)
143 8
		{
144
			$output .= $listElement->html($outputItem);
145
		}
146
		$output .= Module\Hook::trigger('adminPanelEnd');
147
		return $output;
148
	}
149
150
	/**
151
	 * has the permission
152
	 *
153
	 * @since 4.0.0
154
	 *
155
	 * @param string $type
156 8
	 *
157
	 * @return bool
158 8
	 */
159 8
160 8
	protected function _hasPermission(string $type = null) : bool
161
	{
162 2
		$permissionArray = [];
163
		$accessValidator = new Validator\Access();
164 8
		if ($this->_registry->get('categoriesEdit'))
165
		{
166
			$permissionArray['categories'] = $permissionArray['contents'] = true;
167
		}
168 8
		if ($this->_registry->get('articlesEdit'))
169
		{
170
			$permissionArray['articles'] = $permissionArray['contents'] = true;
171
		}
172 8
		if ($this->_registry->get('extrasEdit'))
173
		{
174
			$permissionArray['extras'] = $permissionArray['contents'] = true;
175
		}
176 8
		if ($this->_registry->get('commentsEdit'))
177
		{
178 2
			$permissionArray['comments'] = $permissionArray['contents'] = true;
179
		}
180 8
		if ($this->_registry->get('usersEdit'))
181
		{
182
			$permissionArray['users'] = $permissionArray['access'] = true;
183
		}
184 8
		if ($this->_registry->get('groupsEdit'))
185
		{
186 1
			$permissionArray['groups'] = $permissionArray['access'] = true;
187
		}
188 8
		if ($this->_registry->get('modulesEdit'))
189
		{
190 1
			$permissionArray['modules'] = $permissionArray['system'] = true;
191
		}
192 8
		if ($this->_registry->get('settingsEdit'))
193
		{
194 1
			$permissionArray['settings'] = $permissionArray['system'] = true;
195
		}
196 8
		if ($this->_registry->get('myId'))
197
		{
198 1
			$permissionArray['profile'] = true;
199
		}
200 8
		if ($accessValidator->validate(1, $this->_registry->get('myGroups')))
0 ignored issues
show
Bug introduced by Henry Ruhs
It seems like $this->_registry->get('myGroups') targeting Redaxscript\Registry::get() can also be of type array; however, Redaxscript\Validator\Access::validate() does only seem to accept null|string, maybe add an additional type check?

This check looks at variables that are passed out again to other methods.

If the outgoing method call has stricter type requirements than the method itself, an issue is raised.

An additional type check may prevent trouble.

Loading history...
201
		{
202
			$permissionArray['notification'] = true;
203
		}
204
		return array_key_exists($type, $permissionArray);
205
	}
206
207
	/**
208
	 * render the content
209
	 *
210
	 * @since 4.0.0
211 2
	 *
212
	 * @return string|null
213 2
	 */
214 2
215
	protected function _renderContent() : ?string
216
	{
217 2
		$output = null;
218
		$parameterRoute = $this->_registry->get('parameterRoute');
219
		$contentArray =
220
		[
221
			'categories',
222
			'articles',
223
			'extras',
224
			'comments'
225 2
		];
226
227 2
		/* html element */
228 2
229
		$element = new Html\Element();
230 2
		$listElement = $element
231
			->copy()
232 2
			->init('ul',
233 2
			[
234
				'class' => $this->_optionArray['className']['list']['content']
235 2
			]);
236 2
		$itemElement = $element->copy()->init('li');
237
		$linkElement = $element->copy()->init('a');
238 2
		$textElement = $element
239
			->copy()
240
			->init('span',
241 2
			[
242 2
				'class' => $this->_optionArray['className']['text']
243
			]);
244 2
		$labelElement = $element
245
			->copy()
246
			->init('label',
247 2
			[
248
				'class' => $this->_optionArray['className']['label']['content'],
249 2
				'for' => self::class . '\Content'
250 2
			])
251
			->text($this->_language->get('contents'));
0 ignored issues
show
Bug introduced by Henry Ruhs
It seems like $this->_language->get('contents') targeting Redaxscript\Language::get() can also be of type array; however, Redaxscript\Html\Element::text() does only seem to accept string|integer|null, maybe add an additional type check?

This check looks at variables that are passed out again to other methods.

If the outgoing method call has stricter type requirements than the method itself, an issue is raised.

An additional type check may prevent trouble.

Loading history...
252 2
		$inputElement = $element
253 2
			->copy()
254 2
			->init('input',
255
			[
256
				'id' => self::class . '\Content',
257
				'class' => $this->_optionArray['className']['input'],
258
				'type' => 'radio',
259
				'name' => self::class . '\Panel'
260 2
			]);
261
262 2
		/* process contents */
263 2
264
		foreach ($contentArray as $type)
265 2
		{
266
			$tableNew = $this->_registry->get($type . 'New');
267 2
			if ($this->_hasPermission($type))
268 2
			{
269
				$listElement->append(
270 2
					$itemElement
271 2
						->copy()
272
						->html(
273 2
							$textElement
274 2
								->copy()
275 2
								->append(
276 2
									$linkElement
277
										->copy()
278 2
										->addClass($this->_optionArray['className']['link']['view'])
279 1
										->attr('href', $parameterRoute . 'admin/view/' . $type)
280 1
										->text($this->_language->get($type))
0 ignored issues
show
Bug introduced by Henry Ruhs
It seems like $this->_language->get($type) targeting Redaxscript\Language::get() can also be of type array; however, Redaxscript\Html\Element::text() does only seem to accept string|integer|null, maybe add an additional type check?

This check looks at variables that are passed out again to other methods.

If the outgoing method call has stricter type requirements than the method itself, an issue is raised.

An additional type check may prevent trouble.

Loading history...
281 1
								)
282 2
								->append($tableNew ? $linkElement
0 ignored issues
show
Bug introduced by redaxmedia
It seems like $tableNew ? $linkElement...age->get('new')) : null can also be of type object<Redaxscript\Html\Element>; however, Redaxscript\Html\HtmlAbstract::append() does only seem to accept null|string, maybe add an additional type check?

If a method or function can return multiple different values and unless you are sure that you only can receive a single value in this context, we recommend to add an additional type check:

/**
 * @return array|string
 */
function returnsDifferentValues($x) {
    if ($x) {
        return 'foo';
    }

    return array();
}

$x = returnsDifferentValues($y);
if (is_array($x)) {
    // $x is an array.
}

If this a common case that PHP Analyzer should handle natively, please let us know by opening an issue.

Loading history...
283
									->copy()
284
									->addClass($this->_optionArray['className']['link']['new'])
285
									->attr('href', $parameterRoute . 'admin/new/' . $type)
286
									->text($this->_language->get('new')) : null
0 ignored issues
show
Bug introduced by Henry Ruhs
It seems like $this->_language->get('new') targeting Redaxscript\Language::get() can also be of type array; however, Redaxscript\Html\Element::text() does only seem to accept string|integer|null, maybe add an additional type check?

This check looks at variables that are passed out again to other methods.

If the outgoing method call has stricter type requirements than the method itself, an issue is raised.

An additional type check may prevent trouble.

Loading history...
287
								)
288
						)
289
				);
290
			}
291
		}
292 2
293 2
		/* collect output */
294 2
295 2
		$output .= $itemElement
296
			->copy()
297
			->addClass($this->_optionArray['className']['item']['content'])
298
			->html($inputElement . $labelElement . $listElement);
299
		return $output;
300
	}
301
302
	/**
303
	 * render the access
304
	 *
305
	 * @since 4.0.0
306 2
	 *
307
	 * @return string|null
308 2
	 */
309 2
310
	protected function _renderAccess() : ?string
311
	{
312 2
		$output = null;
313
		$parameterRoute = $this->_registry->get('parameterRoute');
314
		$accessArray =
315
		[
316
			'users',
317
			'groups'
318 2
		];
319
320 2
		/* html element */
321 2
322
		$element = new Html\Element();
323 2
		$listElement = $element
324
			->copy()
325 2
			->init('ul',
326 2
			[
327
				'class' => $this->_optionArray['className']['list']['access']
328 2
			]);
329 2
		$itemElement = $element->copy()->init('li');
330
		$linkElement = $element->copy()->init('a');
331 2
		$textElement = $element
332
			->copy()
333
			->init('span',
334 2
			[
335 2
				'class' => $this->_optionArray['className']['text']
336
			]);
337 2
		$labelElement = $element
338
			->copy()
339
			->init('label',
340 2
			[
341
				'class' => $this->_optionArray['className']['label']['access'],
342 2
				'for' => self::class . '\Access'
343 2
			])
344
			->text($this->_language->get('access'));
0 ignored issues
show
Bug introduced by Henry Ruhs
It seems like $this->_language->get('access') targeting Redaxscript\Language::get() can also be of type array; however, Redaxscript\Html\Element::text() does only seem to accept string|integer|null, maybe add an additional type check?

This check looks at variables that are passed out again to other methods.

If the outgoing method call has stricter type requirements than the method itself, an issue is raised.

An additional type check may prevent trouble.

Loading history...
345 2
		$inputElement = $element
346 2
			->copy()
347 2
			->init('input',
348
			[
349
				'id' => self::class . '\Access',
350
				'class' => $this->_optionArray['className']['input'],
351
				'type' => 'radio',
352
				'name' => self::class . '\Panel'
353 2
			]);
354
355 2
		/* process access */
356 2
357
		foreach ($accessArray as $type)
358 2
		{
359
			$tableNew = $this->_registry->get($type . 'New');
360 2
			if ($this->_hasPermission($type))
361 2
			{
362
				$listElement->append(
363 2
					$itemElement
364 2
						->copy()
365
						->html(
366 2
							$textElement
367 2
								->copy()
368 2
								->append(
369 2
									$linkElement
370
										->copy()
371 2
										->addClass($this->_optionArray['className']['link']['view'])
372 1
										->attr('href', $parameterRoute . 'admin/view/' . $type)
373 1
										->text($this->_language->get($type))
0 ignored issues
show
Bug introduced by Henry Ruhs
It seems like $this->_language->get($type) targeting Redaxscript\Language::get() can also be of type array; however, Redaxscript\Html\Element::text() does only seem to accept string|integer|null, maybe add an additional type check?

This check looks at variables that are passed out again to other methods.

If the outgoing method call has stricter type requirements than the method itself, an issue is raised.

An additional type check may prevent trouble.

Loading history...
374 1
								)
375 2
								->append($tableNew ? $linkElement
0 ignored issues
show
Bug introduced by redaxmedia
It seems like $tableNew ? $linkElement...age->get('new')) : null can also be of type object<Redaxscript\Html\Element>; however, Redaxscript\Html\HtmlAbstract::append() does only seem to accept null|string, maybe add an additional type check?

If a method or function can return multiple different values and unless you are sure that you only can receive a single value in this context, we recommend to add an additional type check:

/**
 * @return array|string
 */
function returnsDifferentValues($x) {
    if ($x) {
        return 'foo';
    }

    return array();
}

$x = returnsDifferentValues($y);
if (is_array($x)) {
    // $x is an array.
}

If this a common case that PHP Analyzer should handle natively, please let us know by opening an issue.

Loading history...
376
									->copy()
377
									->addClass($this->_optionArray['className']['link']['new'])
378
									->attr('href', $parameterRoute . 'admin/new/' . $type)
379
									->text($this->_language->get('new')) : null
0 ignored issues
show
Bug introduced by Henry Ruhs
It seems like $this->_language->get('new') targeting Redaxscript\Language::get() can also be of type array; however, Redaxscript\Html\Element::text() does only seem to accept string|integer|null, maybe add an additional type check?

This check looks at variables that are passed out again to other methods.

If the outgoing method call has stricter type requirements than the method itself, an issue is raised.

An additional type check may prevent trouble.

Loading history...
380
								)
381
						)
382
				);
383
			}
384
		}
385 2
386 2
		/* collect output */
387 2
388 2
		$output .= $itemElement
389
			->copy()
390
			->addClass($this->_optionArray['className']['item']['access'])
391
			->html($inputElement . $labelElement . $listElement);
392
		return $output;
393
	}
394
395
	/**
396
	 * render the system
397
	 *
398
	 * @since 4.0.0
399 1
	 *
400
	 * @return string|null
401 1
	 */
402 1
403
	protected function _renderSystem() : ?string
404
	{
405 1
		$output = null;
406
		$parameterRoute = $this->_registry->get('parameterRoute');
407
		$systemArray =
408
		[
409
			'modules',
410
			'settings'
411 1
		];
412
413 1
		/* html element */
414 1
415
		$element = new Html\Element();
416 1
		$listElement = $element
417
			->copy()
418 1
			->init('ul',
419
			[
420 1
				'class' => $this->_optionArray['className']['list']['system']
421 1
			]);
422
		$itemElement = $element->copy()->init('li');
423 1
		$linkElement = $element
424
			->copy()
425
			->init('a',
426 1
			[
427 1
				'class' => $this->_optionArray['className']['link']['system'],
428
			]);
429 1
		$labelElement = $element
430
			->copy()
431
			->init('label',
432 1
			[
433
				'class' => $this->_optionArray['className']['label']['system'],
434 1
				'for' => self::class . '\System'
435 1
			])
436
			->text($this->_language->get('system'));
0 ignored issues
show
Bug introduced by Henry Ruhs
It seems like $this->_language->get('system') targeting Redaxscript\Language::get() can also be of type array; however, Redaxscript\Html\Element::text() does only seem to accept string|integer|null, maybe add an additional type check?

This check looks at variables that are passed out again to other methods.

If the outgoing method call has stricter type requirements than the method itself, an issue is raised.

An additional type check may prevent trouble.

Loading history...
437 1
		$inputElement = $element
438 1
			->copy()
439 1
			->init('input',
440
			[
441
				'id' => self::class . '\System',
442
				'class' => $this->_optionArray['className']['input'],
443
				'type' => 'radio',
444
				'name' => self::class . '\Panel'
445 1
			]);
446
447 1
		/* process system */
448
449 1
		foreach ($systemArray as $type)
450
		{
451 1
			if ($this->_hasPermission($type))
452 1
			{
453
				$listElement->append(
454 1
					$itemElement
455 1
						->copy()
456 1
						->html(
457
							$linkElement
458
								->copy()
459
								->attr('href', $type === 'settings' ? $parameterRoute . 'admin/edit/settings' : $parameterRoute . 'admin/view/' . $type)
460
								->text($this->_language->get($type))
0 ignored issues
show
Bug introduced by Henry Ruhs
It seems like $this->_language->get($type) targeting Redaxscript\Language::get() can also be of type array; however, Redaxscript\Html\Element::text() does only seem to accept string|integer|null, maybe add an additional type check?

This check looks at variables that are passed out again to other methods.

If the outgoing method call has stricter type requirements than the method itself, an issue is raised.

An additional type check may prevent trouble.

Loading history...
461
						)
462
				);
463
			}
464
		}
465 1
466 1
		/* collect output */
467 1
468 1
		$output .= $itemElement
469
			->copy()
470
			->addClass($this->_optionArray['className']['item']['system'])
471
			->html($inputElement . $labelElement . $listElement);
472
		return $output;
473
	}
474
475
	/**
476
	 * render the profile
477
	 *
478
	 * @since 4.0.0
479 1
	 *
480
	 * @return string
481 1
	 */
482 1
483
	protected function _renderProfile() : string
484
	{
485
		$parameterRoute = $this->_registry->get('parameterRoute');
486 1
		$myId = $this->_registry->get('myId');
487
488 1
		/* html element */
489 1
490
		$element = new Html\Element();
491 1
		$itemElement = $element
492
			->copy()
493
			->init('li',
494 1
			[
495 1
				'class' => $this->_optionArray['className']['item']['profile']
496
			]);
497 1
		$linkElement = $element
498 1
			->copy()
499
			->init('a',
500 1
			[
501
				'href' => $parameterRoute . 'admin/edit/users/' . $myId,
502
				'class' => $this->_optionArray['className']['link']['profile']
503
			])
504 1
			->text($this->_language->get('profile'));
0 ignored issues
show
Bug introduced by Henry Ruhs
It seems like $this->_language->get('profile') targeting Redaxscript\Language::get() can also be of type array; however, Redaxscript\Html\Element::text() does only seem to accept string|integer|null, maybe add an additional type check?

This check looks at variables that are passed out again to other methods.

If the outgoing method call has stricter type requirements than the method itself, an issue is raised.

An additional type check may prevent trouble.

Loading history...
505 1
506
		/* collect item output */
507
508
		$output = $itemElement->html($linkElement);
509
		return $output;
510
	}
511
512
	/**
513
	 * render the notification
514
	 *
515
	 * @since 4.0.0
516 1
	 *
517
	 * @return string|null
518 1
	 */
519 1
520 1
	protected function _renderNotification() : ?string
521
	{
522
		$output = null;
523
		$adminNotification = new Notification($this->_language);
524 1
		$adminNotification->init(
525
		[
526
			'className' =>
527 1
			[
528
				'list' => $this->_optionArray['className']['list']['notification']
529
			]
530
		]);
531 1
		$notificationArray = $adminNotification->getNotificationArray();
532
		$notificationTotal = 0;
533 1
534 1
		/* html element */
535
536 1
		$element = new Html\Element();
537
		$itemElement = $element
538
			->copy()
539 1
			->init('li',
540 1
			[
541
				'class' => $this->_optionArray['className']['item']['notification']
542 1
			]);
543
		$labelElement = $element
544
			->copy()
545 1
			->init('label',
546
			[
547 1
				'class' => $this->_optionArray['className']['label']['notification'],
548 1
				'for' => self::class . '\Notification'
549
			])
550 1
			->text($this->_language->get('notification'));
0 ignored issues
show
Bug introduced by Henry Ruhs
It seems like $this->_language->get('notification') targeting Redaxscript\Language::get() can also be of type array; however, Redaxscript\Html\Element::text() does only seem to accept string|integer|null, maybe add an additional type check?

This check looks at variables that are passed out again to other methods.

If the outgoing method call has stricter type requirements than the method itself, an issue is raised.

An additional type check may prevent trouble.

Loading history...
551 1
		$inputElement = $element
552 1
			->copy()
553
			->init('input',
554 1
			[
555
				'id' => self::class . '\Notification',
556
				'class' => $this->_optionArray['className']['input'],
557 1
				'type' => 'radio',
558 1
				'name' => self::class . '\Panel',
559
				'checked' => 'checked'
560 1
			]);
561
		$supElement = $element
562 1
			->copy()
563
			->init('sup',
564
			[
565
				'class' => $this->_optionArray['className']['sup']
566 1
			]);
567
568 1
		/* process notification */
569
570 1
		foreach ($notificationArray as $key => $value)
571
		{
572
			$supElement->addClass($this->_optionArray['className']['note'][$key]);
573
			$notificationTotal += count($value);
574 1
		}
575
		$labelElement->append($supElement->text($notificationTotal));
576 1
577
		/* collect item output */
578 1
579
		if ($notificationArray)
0 ignored issues
show
Bug Best Practice introduced by redaxmedia
The expression $notificationArray of type array is implicitly converted to a boolean; are you sure this is intended? If so, consider using ! empty($expr) instead to make it clear that you intend to check for an array without elements.

This check marks implicit conversions of arrays to boolean values in a comparison. While in PHP an empty array is considered to be equal (but not identical) to false, this is not always apparent.

Consider making the comparison explicit by using empty(..) or ! empty(...) instead.

Loading history...
580
		{
581
			$output = $itemElement->html($inputElement . $labelElement . $adminNotification->render());
582
		}
583
		return $output;
584
	}
585
586
	/**
587
	 * render the logout
588
	 *
589 8
	 * @since 4.0.0
590
	 *
591 8
	 * @return string
592
	 */
593
594
	protected function _renderLogout() : string
595 8
	{
596
		$parameterRoute = $this->_registry->get('parameterRoute');
597 8
598 8
		/* html element */
599
600 8
		$element = new Html\Element();
601
		$itemElement = $element
602
			->copy()
603 8
			->init('li',
604 8
			[
605
				'class' => $this->_optionArray['className']['item']['logout']
606 8
			]);
607 8
		$linkElement = $element
608
			->copy()
609 8
			->init('a',
610
			[
611
				'href' => $parameterRoute . 'logout',
612
				'class' => $this->_optionArray['className']['link']['logout']
613 8
			])
614 8
			->text($this->_language->get('logout'));
0 ignored issues
show
Bug introduced by Henry Ruhs
It seems like $this->_language->get('logout') targeting Redaxscript\Language::get() can also be of type array; however, Redaxscript\Html\Element::text() does only seem to accept string|integer|null, maybe add an additional type check?

This check looks at variables that are passed out again to other methods.

If the outgoing method call has stricter type requirements than the method itself, an issue is raised.

An additional type check may prevent trouble.

Loading history...
615
616
		/* collect item output */
617
618
		$output = $itemElement->html($linkElement);
619
		return $output;
620
	}
621
}
622