@@ -124,7 +124,7 @@ private function process($data, $import = true, $path = '#')
124
124
}
125
125
}
126
126
if (!$ enumOk ) {
127
- throw new EnumException ('Enum failed ' . $ path );
127
+ $ this -> fail ( new EnumException ('Enum failed ' ), $ path );
128
128
}
129
129
}
130
130
@@ -135,7 +135,7 @@ private function process($data, $import = true, $path = '#')
135
135
} catch (InvalidValue $ exception ) {
136
136
}
137
137
if ($ exception === false ) {
138
- throw new LogicException ('Failed due to logical constraint: not ' . $ path );
138
+ $ this -> fail ( new LogicException ('Failed due to logical constraint: not ' ), $ path );
139
139
}
140
140
}
141
141
@@ -152,7 +152,7 @@ private function process($data, $import = true, $path = '#')
152
152
}
153
153
}
154
154
if ($ successes !== 1 ) {
155
- throw new LogicException ('Failed due to logical constraint: oneOf ' . $ path );
155
+ $ this -> fail ( new LogicException ('Failed due to logical constraint: oneOf ' ), $ path );
156
156
}
157
157
}
158
158
@@ -169,7 +169,7 @@ private function process($data, $import = true, $path = '#')
169
169
}
170
170
}
171
171
if (!$ successes ) {
172
- throw new LogicException ('Failed due to logical constraint: anyOf ' . $ path );
172
+ $ this -> fail ( new LogicException ('Failed due to logical constraint: anyOf ' ), $ path );
173
173
}
174
174
}
175
175
@@ -183,18 +183,18 @@ private function process($data, $import = true, $path = '#')
183
183
if (is_string ($ data )) {
184
184
if ($ this ->minLength !== null ) {
185
185
if (mb_strlen ($ data ) < $ this ->minLength ) {
186
- throw new StringException ('String is too short ' . $ path , StringException::TOO_SHORT );
186
+ $ this -> fail ( new StringException ('String is too short ' , StringException::TOO_SHORT ), $ path );
187
187
}
188
188
}
189
189
if ($ this ->maxLength !== null ) {
190
190
if (mb_strlen ($ data ) > $ this ->maxLength ) {
191
- throw new StringException ('String is too long ' . $ path , StringException::TOO_LONG );
191
+ $ this -> fail ( new StringException ('String is too long ' , StringException::TOO_LONG ), $ path );
192
192
}
193
193
}
194
194
if ($ this ->pattern !== null ) {
195
195
if (0 === preg_match ($ this ->pattern , $ data )) {
196
- throw new StringException ('Does not match to ' . $ this -> pattern . ' ' . $ path ,
197
- StringException::PATTERN_MISMATCH );
196
+ $ this -> fail ( new StringException ('Does not match to '
197
+ . $ this -> pattern , StringException::PATTERN_MISMATCH ), $ path );
198
198
}
199
199
}
200
200
}
@@ -203,31 +203,30 @@ private function process($data, $import = true, $path = '#')
203
203
if ($ this ->multipleOf !== null ) {
204
204
$ div = $ data / $ this ->multipleOf ;
205
205
if ($ div != (int )$ div ) {
206
- throw new NumericException ($ data . ' is not multiple of ' . $ this ->multipleOf . ' ' . $ path ,
207
- NumericException::MULTIPLE_OF );
206
+ $ this ->fail (new NumericException ($ data . ' is not multiple of ' . $ this ->multipleOf , NumericException::MULTIPLE_OF ), $ path );
208
207
}
209
208
}
210
209
211
210
if ($ this ->maximum !== null ) {
212
211
if ($ this ->exclusiveMaximum === true ) {
213
212
if ($ data >= $ this ->maximum ) {
214
- throw new NumericException ('Maximum value exceeded ' . $ path , NumericException::MAXIMUM );
213
+ $ this -> fail ( new NumericException ('Maximum value exceeded ' , NumericException::MAXIMUM ), $ path );
215
214
}
216
215
} else {
217
216
if ($ data > $ this ->maximum ) {
218
- throw new NumericException ('Maximum value exceeded ' . $ path , NumericException::MAXIMUM );
217
+ $ this -> fail ( new NumericException ('Maximum value exceeded ' , NumericException::MAXIMUM ), $ path );
219
218
}
220
219
}
221
220
}
222
221
223
222
if ($ this ->minimum !== null ) {
224
223
if ($ this ->exclusiveMinimum === true ) {
225
224
if ($ data <= $ this ->minimum ) {
226
- throw new NumericException ('Minimum value exceeded ' . $ path , NumericException::MINIMUM );
225
+ $ this -> fail ( new NumericException ('Minimum value exceeded ' , NumericException::MINIMUM ), $ path );
227
226
}
228
227
} else {
229
228
if ($ data < $ this ->minimum ) {
230
- throw new NumericException ('Minimum value exceeded ' . $ path , NumericException::MINIMUM );
229
+ $ this -> fail ( new NumericException ('Minimum value exceeded ' , NumericException::MINIMUM ), $ path );
231
230
}
232
231
}
233
232
}
@@ -239,8 +238,7 @@ private function process($data, $import = true, $path = '#')
239
238
if ($ this ->required !== null ) {
240
239
foreach ($ this ->required as $ item ) {
241
240
if (!property_exists ($ data , $ item )) {
242
- throw new ObjectException ('Required property missing: ' . $ item . ' ' . $ path ,
243
- ObjectException::REQUIRED );
241
+ $ this ->fail (new ObjectException ('Required property missing: ' . $ item , ObjectException::REQUIRED ), $ path );
244
242
}
245
243
}
246
244
}
@@ -256,10 +254,10 @@ private function process($data, $import = true, $path = '#')
256
254
257
255
$ array = (array )$ data ;
258
256
if ($ this ->minProperties !== null && count ($ array ) < $ this ->minProperties ) {
259
- throw new ObjectException ("Not enough properties " . $ path , ObjectException::TOO_FEW );
257
+ $ this -> fail ( new ObjectException ("Not enough properties " , ObjectException::TOO_FEW ), $ path );
260
258
}
261
259
if ($ this ->maxProperties !== null && count ($ array ) > $ this ->maxProperties ) {
262
- throw new ObjectException ("Too many properties " . $ path , ObjectException::TOO_MANY );
260
+ $ this -> fail ( new ObjectException ("Too many properties " , ObjectException::TOO_MANY ), $ path );
263
261
}
264
262
foreach ($ array as $ key => $ value ) {
265
263
$ found = false ;
@@ -270,8 +268,7 @@ private function process($data, $import = true, $path = '#')
270
268
} else {
271
269
foreach ($ dependencies as $ item ) {
272
270
if (!property_exists ($ data , $ item )) {
273
- throw new ObjectException ('Dependency property missing: ' . $ item . ' ' . $ path ,
274
- ObjectException::DEPENDENCY_MISSING );
271
+ $ this ->fail (new ObjectException ('Dependency property missing: ' . $ item , ObjectException::DEPENDENCY_MISSING ), $ path );
275
272
}
276
273
}
277
274
}
0 commit comments