Passed
Pull Request — master (#449)
by Sergei
02:24
created

AttributesRulesProvider::parseRules()   A

Complexity

Conditions 5
Paths 8

Size

Total Lines 17
Code Lines 11

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 12
CRAP Score 5

Importance

Changes 2
Bugs 0 Features 0
Metric Value
eloc 11
c 2
b 0
f 0
dl 0
loc 17
ccs 12
cts 12
cp 1
rs 9.6111
cc 5
nc 8
nop 0
crap 5
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