Passed
Push — main ( 93f154...8839a5 )
by Roman
13:10 queued 09:41
created

ViewComposerTrait   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 15
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 9
c 1
b 0
f 0
dl 0
loc 15
rs 10
wmc 2

1 Method

Rating   Name   Duplication   Size   Complexity  
A setPageTitle() 0 13 2
1
<?php
2
declare(strict_types=1);
3
4
namespace KielD01\LaravelMaterialDashboardPro\Traits;
5
6
use Illuminate\View\View;
7
8
/**
9
 * Trait ViewComposerTrait
10
 * @package KielD01\LaravelMaterialDashboardPro\Traits
11
 */
12
trait ViewComposerTrait
13
{
14
	protected function setPageTitle(string $pageTitle): void
15
	{
16
		view()
17
			->composer(
18
				['mdp::layouts.main', 'mdp::layouts.user.auth-v1'],
19
				static function (View $view) use ($pageTitle) {
20
					$data = $view->getData();
21
22
					if (array_key_exists('mdp', $data)) {
23
						$data['mdp']->setPageTitle($pageTitle);
24
					}
25
26
					$view->with($data);
27
				}
28
			);
29
	}
30
}
31