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

GeneratorRequest   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 20
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

Changes 2
Bugs 0 Features 0
Metric Value
wmc 3
eloc 6
c 2
b 0
f 0
dl 0
loc 20
ccs 0
cts 8
cp 0
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A getGenerator() 0 9 1
A __construct() 0 2 1
A getAnswers() 0 3 1
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