| @@ 95-110 (lines=16) @@ | ||
| 92 | * |
|
| 93 | * @throws UnsupportedVersionException if the version is not supported |
|
| 94 | */ |
|
| 95 | public function getConstraintsForType($version, $type) |
|
| 96 | { |
|
| 97 | $cache = &$this->constraintsForTypeCache[$version.$type]; |
|
| 98 | ||
| 99 | if ($cache === null) { |
|
| 100 | $cache = []; |
|
| 101 | ||
| 102 | foreach ($this->getConstraints($version) as $constraint) { |
|
| 103 | if ($constraint->supports($type)) { |
|
| 104 | $cache[] = $constraint; |
|
| 105 | } |
|
| 106 | } |
|
| 107 | } |
|
| 108 | ||
| 109 | return $cache; |
|
| 110 | } |
|
| 111 | ||
| 112 | /** |
|
| 113 | * Returns whether a keyword is supported in a given JSON Schema version. |
|
| @@ 120-135 (lines=16) @@ | ||
| 117 | * |
|
| 118 | * @return bool |
|
| 119 | */ |
|
| 120 | public function hasKeyword($version, $keyword) |
|
| 121 | { |
|
| 122 | $cache = &$this->keywordsCache[$version]; |
|
| 123 | ||
| 124 | if ($cache === null) { |
|
| 125 | $cache = []; |
|
| 126 | ||
| 127 | foreach ($this->getConstraints($version) as $constraint) { |
|
| 128 | foreach ($constraint->keywords() as $constraintKeyword) { |
|
| 129 | $cache[$constraintKeyword] = true; |
|
| 130 | } |
|
| 131 | } |
|
| 132 | } |
|
| 133 | ||
| 134 | return isset($cache[$keyword]); |
|
| 135 | } |
|
| 136 | ||
| 137 | /** |
|
| 138 | * Loads the constraints associated with a given JSON Schema version. |
|