1 | <?php |
||
17 | class Registry |
||
18 | { |
||
19 | const VERSION_CURRENT = 'http://json-schema.org/schema#'; |
||
20 | const VERSION_DRAFT_3 = 'http://json-schema.org/draft-03/schema#'; |
||
21 | const VERSION_DRAFT_4 = 'http://json-schema.org/draft-04/schema#'; |
||
22 | |||
23 | private static $commonConstraints = [ |
||
24 | 'Maximum', |
||
25 | 'Minimum', |
||
26 | 'MaxLength', |
||
27 | 'MinLength', |
||
28 | 'Pattern', |
||
29 | 'Items', |
||
30 | 'MaxItems', |
||
31 | 'MinItems', |
||
32 | 'UniqueItems', |
||
33 | 'Required', |
||
34 | 'Properties', |
||
35 | 'Dependencies', |
||
36 | 'Enum', |
||
37 | 'Type', |
||
38 | 'Format', |
||
39 | ]; |
||
40 | |||
41 | private static $draft4Constraints = [ |
||
42 | 'MultipleOf', |
||
43 | 'MinProperties', |
||
44 | 'MaxProperties', |
||
45 | 'AllOf', |
||
46 | 'AnyOf', |
||
47 | 'OneOf', |
||
48 | 'Not', |
||
49 | ]; |
||
50 | |||
51 | /** |
||
52 | * @var Constraint[][] |
||
53 | */ |
||
54 | private $constraints = []; |
||
55 | |||
56 | /** |
||
57 | * Returns the constraints associated with a given JSON Schema version. |
||
58 | * |
||
59 | * @param string $version |
||
60 | * |
||
61 | * @return Constraint[] |
||
62 | * |
||
63 | * @throws \Exception if the version is not supported |
||
64 | */ |
||
65 | 358 | public function getConstraints($version) |
|
73 | |||
74 | /** |
||
75 | * Loads the constraints associated with a given JSON Schema version. |
||
76 | * |
||
77 | * @param string $version |
||
78 | * |
||
79 | * @return Constraint[] |
||
80 | * |
||
81 | * @throws \Exception if the version is not supported |
||
82 | */ |
||
83 | 358 | protected function createConstraints($version) |
|
100 | |||
101 | private function createBuiltInConstraints(array $constraintNames) |
||
109 | } |
||
110 |