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

PureInputData::withName()   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 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 0
b 0
f 0
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Yiisoft\Form\Field\Base\InputData;
6
7
final class PureInputData implements InputDataInterface
8
{
9 119
    public function __construct(
10
        private ?string $name = null,
11
        private mixed $value = null,
12
    ) {
13 119
    }
14
15
    public function getValidationRules(): array
16
    {
17
        return [];
18
    }
19
20 2
    public function getName(): ?string
21
    {
22 2
        return $this->name;
23
    }
24
25 2
    public function getValue(): mixed
26
    {
27 2
        return $this->value;
28
    }
29
30 108
    public function getLabel(): ?string
31
    {
32 108
        return null;
33
    }
34
35 108
    public function getHint(): ?string
36
    {
37 108
        return null;
38
    }
39
40 2
    public function getPlaceholder(): ?string
41
    {
42 2
        return null;
43
    }
44
45 8
    public function getId(): ?string
46
    {
47 8
        return null;
48
    }
49
50 2
    public function isValidated(): bool
51
    {
52 2
        return false;
53
    }
54
55 108
    public function getValidationErrors(): array
56
    {
57 108
        return [];
58
    }
59
60 2
    public function withName(?string $name): static
61
    {
62 2
        $new = clone $this;
63 2
        $new->name = $name;
64 2
        return $new;
65
    }
66
67 1
    public function withValue(mixed $value): static
68
    {
69 1
        $new = clone $this;
70 1
        $new->value = $value;
71 1
        return $new;
72
    }
73
}
74