Passed
Pull Request — master (#122)
by Sergei
13:55
created

ApplicationViewInjection   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 44
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 20
c 0
b 0
f 0
dl 0
loc 44
rs 10
wmc 4

4 Methods

Rating   Name   Duplication   Size   Complexity  
A getLayoutParameters() 0 6 1
A getMetaTags() 0 7 1
A getLinkTags() 0 7 1
A __construct() 0 6 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace App;
6
7
use Yiisoft\Router\UrlMatcherInterface;
8
use Yiisoft\Yii\View\LayoutParametersInjectionInterface;
0 ignored issues
show
Bug introduced by
The type Yiisoft\Yii\View\LayoutP...etersInjectionInterface 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...
9
use Yiisoft\Yii\View\LinkTagsInjectionInterface;
10
use Yiisoft\Yii\View\MetaTagsInjectionInterface;
11
use Yiisoft\Yii\Web\User\User;
12
13
class ApplicationViewInjection implements
14
    LayoutParametersInjectionInterface,
15
    MetaTagsInjectionInterface,
16
    LinkTagsInjectionInterface
17
{
18
19
    private User $user;
20
    private UrlMatcherInterface $urlMatcher;
21
22
    public function __construct(
23
        User $user,
24
        UrlMatcherInterface $urlMatcher
25
    ) {
26
        $this->user = $user;
27
        $this->urlMatcher = $urlMatcher;
28
    }
29
30
    public function getLayoutParameters(): array
31
    {
32
        return [
33
            'user' => $this->user->getIdentity(),
34
            'currentUrl' => (string)$this->urlMatcher->getLastMatchedRequest()->getUri(),
35
            'brandLabel' => 'Yii Demo',
36
        ];
37
    }
38
39
    public function getMetaTags(): array
40
    {
41
        return [
42
            [
43
                '__key' => 'generator',
44
                'name' => 'generator',
45
                'value' => 'Yii',
46
            ],
47
        ];
48
    }
49
50
    public function getLinkTags(): array
51
    {
52
        return [
53
            [
54
                '__key' => 'favicon',
55
                'name' => 'icon',
56
                'value' => '/favicon.ico',
57
            ],
58
        ];
59
    }
60
}
61