ContentViewInjection::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 8
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 3
nc 1
nop 3
dl 0
loc 8
ccs 4
cts 4
cp 1
crap 1
rs 10
c 1
b 0
f 0
1
<?php
2
3
declare(strict_types=1);
4
5
namespace App\ViewInjection;
6
7
use Yiisoft\Form\Widget\Field;
8
use Yiisoft\Router\UrlGeneratorInterface;
9
use Yiisoft\Router\UrlMatcherInterface;
10
use Yiisoft\Yii\View\ContentParametersInjectionInterface;
11
12
class ContentViewInjection implements ContentParametersInjectionInterface
13
{
14
    private UrlMatcherInterface $urlMatcher;
15
    private UrlGeneratorInterface $url;
16
    private Field $field;
17
18 10
    public function __construct(
19
        UrlMatcherInterface $urlMatcher,
20
        UrlGeneratorInterface $url,
21
        Field $field
22
    ) {
23 10
        $this->urlMatcher = $urlMatcher;
24 10
        $this->url = $url;
25 10
        $this->field = $field;
26 10
    }
27
28 10
    public function getContentParameters(): array
29
    {
30
        return [
31 10
            'field' => $this->field,
32 10
            'url' => $this->url,
33 10
            'urlMatcher' => $this->urlMatcher,
34
        ];
35
    }
36
}
37