Passed
Push — dependabot/github_actions/acti... ( 6c9f07 )
by
unknown
14:42 queued 10:29
created

HiddenInput   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 36
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 13
c 1
b 0
f 0
dl 0
loc 36
ccs 11
cts 11
cp 1
rs 10
wmc 2

2 Methods

Rating   Name   Duplication   Size   Complexity  
A config() 0 7 1
A run() 0 6 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Yiisoft\Form\Widget;
6
7
use Yiisoft\Form\FormModelInterface;
8
use Yiisoft\Widget\Widget;
9
10
final class HiddenInput extends Widget
11
{
12
    private FormModelInterface $data;
13
    private string $attribute;
14
    private array $options = [];
15
16
    /**
17
     * Generates a hidden input tag for the given form attribute.
18
     *
19
     * @return string the generated input tag.
20
     */
21 15
    public function run(): string
22
    {
23 15
        return Input::widget()
24 15
            ->type('hidden')
0 ignored issues
show
Bug introduced by
The method type() does not exist on Yiisoft\Widget\Widget. It seems like you code against a sub-type of Yiisoft\Widget\Widget such as Yiisoft\Form\Widget\ListBox or Yiisoft\Form\Widget\Input or Yiisoft\Form\Widget\ListInput or Yiisoft\Form\Widget\BooleanInput. ( Ignorable by Annotation )

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

24
            ->/** @scrutinizer ignore-call */ type('hidden')
Loading history...
25 15
            ->config($this->data, $this->attribute, $this->options)
26 15
            ->run();
27
    }
28
29
    /**
30
     * Set form model, name and options for the widget.
31
     *
32
     * @param FormModelInterface $data Form model.
33
     * @param string $attribute Form model property this widget is rendered for.
34
     * @param array $options The HTML attributes for the widget container tag.
35
     * See {@see \Yiisoft\Html\Html::renderTagAttributes()} for details on how attributes are being rendered.
36
     *
37
     * @return self
38
     */
39 15
    public function config(FormModelInterface $data, string $attribute, array $options = []): self
40
    {
41 15
        $new = clone $this;
42 15
        $new->data = $data;
43 15
        $new->attribute = $attribute;
44 15
        $new->options = $options;
45 15
        return $new;
46
    }
47
}
48