Passed
Pull Request — master (#449)
by Alexander
04:48 queued 02:22
created

AttributesRulesProvider::createAttributes()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 2

Importance

Changes 0
Metric Value
eloc 2
c 0
b 0
f 0
dl 0
loc 4
ccs 3
cts 3
cp 1
rs 10
cc 2
nc 2
nop 1
crap 2
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Yiisoft\Validator\RulesProvider;
6
7
use ReflectionProperty;
8
use Yiisoft\Validator\Helper\ObjectParser;
9
use Yiisoft\Validator\RulesProviderInterface;
10
11
final class AttributesRulesProvider implements RulesProviderInterface
12
{
13
    private ObjectParser $parser;
14
15
    /**
16
     * @param class-string|object $source
0 ignored issues
show
Documentation Bug introduced by
The doc comment class-string|object at position 0 could not be parsed: Unknown type name 'class-string' at position 0 in class-string|object.
Loading history...
17
     */
18
    public function __construct(
19
        string|object $source,
20
        int $propertyVisibility = ReflectionProperty::IS_PRIVATE
21 16
        | ReflectionProperty::IS_PROTECTED
22
        | ReflectionProperty::IS_PUBLIC,
23
        bool $skipStaticProperties = false,
24
    ) {
25
        $this->parser = new ObjectParser($source, $propertyVisibility, $skipStaticProperties);
26
    }
27
28
    public function getRules(): iterable
29
    {
30
        return $this->parser->getRules();
31
    }
32
}
33