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