Conditions | 4 |
Paths | 6 |
Total Lines | 47 |
Code Lines | 33 |
Lines | 0 |
Ratio | 0 % |
Tests | 8 |
CRAP Score | 4 |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
45 | 45 | public static function loadRestriction( |
|
46 | SchemaReader $reader, |
||
47 | Type $type, |
||
48 | DOMElement $node |
||
49 | ) { |
||
50 | 45 | $restriction = new Restriction(); |
|
51 | 45 | $type->setRestriction($restriction); |
|
52 | 45 | if ($node->hasAttribute("base")) { |
|
53 | 45 | $reader->findAndSetSomeBase($type, $restriction, $node); |
|
54 | } else { |
||
55 | 45 | $addCallback = function (Type $restType) use ($restriction) { |
|
56 | 45 | $restriction->setBase($restType); |
|
57 | 45 | }; |
|
58 | |||
59 | Type::loadTypeWithCallbackOnChildNodes( |
||
60 | $reader, |
||
61 | $type->getSchema(), |
||
62 | $node, |
||
63 | $addCallback |
||
64 | ); |
||
65 | } |
||
66 | foreach ($node->childNodes as $childNode) { |
||
67 | if ( |
||
68 | in_array( |
||
69 | $childNode->localName, |
||
70 | [ |
||
71 | 'enumeration', |
||
72 | 'pattern', |
||
73 | 'length', |
||
74 | 'minLength', |
||
75 | 'maxLength', |
||
76 | 'minInclusive', |
||
77 | 'maxInclusive', |
||
78 | 'minExclusive', |
||
79 | 'maxExclusive', |
||
80 | 'fractionDigits', |
||
81 | 'totalDigits', |
||
82 | 'whiteSpace' |
||
83 | ], |
||
84 | true |
||
85 | ) |
||
86 | ) { |
||
87 | $restriction->addCheck( |
||
88 | $childNode->localName, |
||
89 | [ |
||
90 | 'value' => $childNode->getAttribute("value"), |
||
91 | 'doc' => SchemaReader::getDocumentation($childNode) |
||
92 | ] |
||
98 |