Passed
Pull Request — master (#281)
by Sergei
02:50
created

CustomNameAndValueForInputDataTrait::value()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 3
nc 1
nop 1
dl 0
loc 5
ccs 4
cts 4
cp 1
crap 1
rs 10
c 1
b 0
f 0
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Yiisoft\Form\Field\Base\InputData;
6
7
trait CustomNameAndValueForInputDataTrait
8
{
9 3
    final public function name(?string $name): static
10
    {
11 3
        $new = clone $this;
12 3
        $new->inputData = $this->getInputData()->withName($name);
0 ignored issues
show
Bug introduced by
It seems like getInputData() must be provided by classes using this trait. How about adding it as abstract method to this trait? ( Ignorable by Annotation )

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

12
        $new->inputData = $this->/** @scrutinizer ignore-call */ getInputData()->withName($name);
Loading history...
Bug Best Practice introduced by
The property inputData does not exist. Although not strictly required by PHP, it is generally a best practice to declare properties explicitly.
Loading history...
13 3
        return $new;
14
    }
15
16 2
    final public function value(mixed $value): static
17
    {
18 2
        $new = clone $this;
19 2
        $new->inputData = $this->getInputData()->withValue($value);
0 ignored issues
show
Bug Best Practice introduced by
The property inputData does not exist. Although not strictly required by PHP, it is generally a best practice to declare properties explicitly.
Loading history...
20 2
        return $new;
21
    }
22
}
23