Passed
Pull Request — master (#122)
by
unknown
16:22 queued 01:22
created

ApplicationInjection   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 41
Duplicated Lines 0 %

Importance

Changes 2
Bugs 0 Features 0
Metric Value
eloc 17
c 2
b 0
f 0
dl 0
loc 41
rs 10
wmc 4

4 Methods

Rating   Name   Duplication   Size   Complexity  
A getLayoutParams() 0 6 1
A __construct() 0 6 1
A getLinkTags() 0 7 1
A getMetaTags() 0 7 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace App\ViewRenderer;
6
7
use Yiisoft\Router\UrlMatcherInterface;
8
use Yiisoft\Yii\Web\User\User;
9
10
class ApplicationInjection extends AbstractInjection
11
{
12
13
    private User $user;
14
    private UrlMatcherInterface $urlMatcher;
15
16
    public function __construct(
17
        User $user,
18
        UrlMatcherInterface $urlMatcher
19
    ) {
20
        $this->user = $user;
21
        $this->urlMatcher = $urlMatcher;
22
    }
23
24
    public function getLayoutParams(): array
25
    {
26
        return [
27
            'user' => $this->user->getIdentity(),
28
            'currentUrl' => (string)$this->urlMatcher->getLastMatchedRequest()->getUri(),
29
            'brandLabel' => 'Yii Demo',
30
        ];
31
    }
32
33
    public function getMetaTags(): array
34
    {
35
        return [
36
            [
37
                '__key' => 'generator',
38
                'name' => 'generator',
39
                'value' => 'Yii',
40
            ],
41
        ];
42
    }
43
44
    public function getLinkTags(): array
45
    {
46
        return [
47
            [
48
                '__key' => 'favicon',
49
                'name' => 'icon',
50
                'value' => 'favicon.ico',
51
            ],
52
        ];
53
    }
54
}
55