Passed
Pull Request — master (#192)
by Alexander
02:53
created

ReadonlyTrait::readonly()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 2
Bugs 0 Features 0
Metric Value
cc 1
eloc 3
nc 1
nop 1
dl 0
loc 5
ccs 0
cts 4
cp 0
crap 2
rs 10
c 2
b 0
f 0
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Yiisoft\Form\Field\Base;
6
7
/**
8
 * @psalm-require-extends AbstractField
9
 */
10
trait ReadonlyTrait
11
{
12
    /**
13
     * A boolean attribute that controls whether or not the user can edit the form control.
14
     *
15
     * @param bool $value Whether to allow the value to be edited by the user.
16
     *
17
     * @link https://html.spec.whatwg.org/multipage/input.html#attr-input-readonly
18
     */
19
    public function readonly(bool $value = true): static
20
    {
21
        $new = clone $this;
22
        $new->inputTagAttributes['readonly'] = $value;
0 ignored issues
show
Bug Best Practice introduced by
The property inputTagAttributes does not exist. Although not strictly required by PHP, it is generally a best practice to declare properties explicitly.
Loading history...
23
        return $new;
24
    }
25
}
26