Test Failed
Push — required-aria-attribute ( 00f2fd )
by Dmitriy
03:11
created

RequiredHtmlOptions::withAriaAttribute()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 3
c 0
b 0
f 0
nc 1
nop 1
dl 0
loc 5
rs 10
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Yiisoft\Form\HtmlOptions;
6
7
use Yiisoft\Validator\Rule\Required;
8
use Yiisoft\Validator\ValidatorRuleInterface;
0 ignored issues
show
Bug introduced by
The type Yiisoft\Validator\ValidatorRuleInterface was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
9
10
class RequiredHtmlOptions implements HtmlOptionsProvider, ValidatorRuleInterface
11
{
12
    use ValidatorAwareTrait;
13
14
    private bool $ariaAttribute = false;
15
16
    public function __construct(Required $validator)
17
    {
18
        $this->validator = $validator;
19
    }
20
21
    public function withAriaAttribute(bool $value): self
22
    {
23
        $new = clone $this;
24
        $new->ariaAttribute = $value;
25
        return $new;
26
    }
27
28
    public function getHtmlOptions(): array
29
    {
30
        return [
31
            'required' => true,
32
            'aria-required' => $this->ariaAttribute ? 'true' : false,
33
        ];
34
    }
35
}
36