Passed
Pull Request — master (#56)
by Rustam
02:34
created

GeneratorRequest::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 2
Code Lines 0

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 0
c 1
b 0
f 0
dl 0
loc 2
ccs 0
cts 1
cp 0
rs 10
cc 1
nc 1
nop 1
crap 2
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Yiisoft\Yii\Gii\Request;
6
7
use Yiisoft\RequestModel\RequestModel;
8
use Yiisoft\Yii\Gii\Generator\AbstractGenerator;
9
use Yiisoft\Yii\Gii\GeneratorInterface;
10
use Yiisoft\Yii\Gii\GiiInterface;
11
12
final class GeneratorRequest extends RequestModel
13
{
14
    public function __construct(private GiiInterface $gii)
15
    {
16
    }
17
18
    public function getGenerator(): GeneratorInterface
19
    {
20
        /** @var AbstractGenerator $generator */
21
        $generator = $this->gii->getGenerator($this->getAttributeValue('router.generator'));
22
23
        $generator->loadStickyAttributes();
24
        $generator->load((array)$this->getAttributeValue('body'));
25
26
        return $generator;
27
    }
28
29
    public function getAnswers(): ?array
30
    {
31
        return $this->getAttributeValue('body.answers');
32
    }
33
}
34