Test Failed
Pull Request — master (#494)
by
unknown
03:32
created

LayoutViewInjection::getLayoutParameters()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 7
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 2
eloc 4
nc 2
nop 0
dl 0
loc 7
rs 10
c 0
b 0
f 0
1
<?php
2
3
declare(strict_types=1);
4
5
namespace App\Http\ViewInjection;
6
7
use App\Modules\Auth\Identity;
8
use Yiisoft\User\CurrentUser;
9
use Yiisoft\Yii\View\LayoutParametersInjectionInterface;
10
11
final class LayoutViewInjection implements LayoutParametersInjectionInterface
12
{
13
    public function __construct(private CurrentUser $currentUser)
14
    {
15
    }
16
17
    public function getLayoutParameters(): array
18
    {
19
        $identity = $this->currentUser->getIdentity();
20
21
        return [
22
            'brandLabel' => 'Yii Demo',
23
            'user' => $identity instanceof Identity ? $identity->getUser() : null,
24
        ];
25
    }
26
}
27