Passed
Push — feature/issue-124 ( 91e4aa...dde646 )
by Mikaël
09:46
created

ListRule   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 15
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 4
c 1
b 0
f 0
dl 0
loc 15
ccs 6
cts 6
cp 1
rs 10
wmc 3

3 Methods

Rating   Name   Duplication   Size   Complexity  
A name() 0 3 1
A getParameterPassedValue() 0 3 1
A mustApplyRuleOnAttribute() 0 3 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace WsdlToPhp\PackageGenerator\File\Validation;
6
7
/**
8
 * @see https://www.w3.org/TR/xmlschema-2/#list-datatypes
9
 */
10
final class ListRule extends AbstractSetOfValuesRule
11
{
12 6
    public function name(): string
13
    {
14 6
        return 'list';
15
    }
16
17 6
    public static function getParameterPassedValue(string $parameterName): string
18
    {
19 6
        return sprintf('is_string($%1$s) ? explode(\' \', $%1$s) : $%1$s', $parameterName);
20
    }
21
22 6
    protected function mustApplyRuleOnAttribute(): bool
23
    {
24 6
        return $this->getAttribute()->isList();
25
    }
26
}
27