File tree Expand file tree Collapse file tree 2 files changed +18
-1
lines changed
Expand file tree Collapse file tree 2 files changed +18
-1
lines changed Original file line number Diff line number Diff line change 11<?php namespace Locker \XApi ;
2+ use Locker \XApi \Errors \Error as Error ;
23
34class StatementBase extends Element {
45 protected $ props = [
@@ -11,4 +12,20 @@ class StatementBase extends Element {
1112 'attachments ' => 'Locker\XApi\Attachments '
1213 ];
1314 protected $ required_props = ['actor ' , 'verb ' , 'object ' ];
15+
16+ public function validate () {
17+ $ errors = [];
18+ $ verb_id = $ this ->getPropValue ('verb.id ' );
19+ $ object_type = $ this ->getPropValue ('object.objectType ' );
20+
21+ // Validates voider.
22+ if (
23+ $ verb_id === 'http://adlnet.gov/expapi/verbs/voided ' &&
24+ $ object_type !== 'StatementRef '
25+ ) {
26+ $ errors [] = new Error ("`object.objectType` must be `StatementRef` not ` $ object_type` when voiding " );
27+ }
28+
29+ return array_merge ($ errors , parent ::validate ());
30+ }
1431}
Original file line number Diff line number Diff line change 33
44use Locker \XApi as XApi ;
55
6-
6+ header ( ' Content-Type: application/json ' );
77try {
88 // Code.
99 $ file_location = 'assets/test.json ' ;
You can’t perform that action at this time.
0 commit comments