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