Test Failed
Pull Request — master (#159)
by Sergei
02:19
created

FieldFactory::setTemplate()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 1
c 1
b 0
f 0
nc 1
nop 1
dl 0
loc 3
rs 10
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Yiisoft\Form;
6
7
use Yiisoft\Form\Field\InputText;
8
9
final class FieldFactory
10
{
11
    private ?string $template = null;
12
13
    public function setTemplate(?string $template): void
14
    {
15
        $this->template = $template;
16
    }
17
18
    public function text(FormModelInterface $formModel, string $attribute): InputText
19
    {
20
        $widget = InputText::widget()->attribute($formModel, $attribute);
0 ignored issues
show
Bug introduced by
The method attribute() does not exist on Yiisoft\Widget\Widget. It seems like you code against a sub-type of Yiisoft\Widget\Widget such as Yiisoft\Form\Field\Base\AbstractField. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

20
        $widget = InputText::widget()->/** @scrutinizer ignore-call */ attribute($formModel, $attribute);
Loading history...
21
22
        if ($this->template !== null) {
23
            $widget = $widget->template($this->template);
24
        }
25
26
        return $widget;
27
    }
28
}
29