ILIAS  release_7 Revision v7.30-3-g800a261c036
ilTermsOfServiceAcceptanceHistoryCriteriaBag Class Reference

Class ilTermsOfServiceAcceptanceHistoryCriteriaBag. More...

+ Inheritance diagram for ilTermsOfServiceAcceptanceHistoryCriteriaBag:
+ Collaboration diagram for ilTermsOfServiceAcceptanceHistoryCriteriaBag:

Public Member Functions

 __construct ($data=[])
 ilTermsOfServiceAcceptanceHistoryCriteriaBag constructor. More...
 
 toJson ()
 
 fromJson (string $json)
 
Parameters
string$json
More...
 
 jsonSerialize ()
 
 toJson ()
 
 fromJson (string $json)
 

Private Member Functions

 ensureValidArrayTypes (array $data)
 
 ensureValidInternalTypes (array $data)
 

Detailed Description

Constructor & Destructor Documentation

◆ __construct()

ilTermsOfServiceAcceptanceHistoryCriteriaBag::__construct (   $data = [])

ilTermsOfServiceAcceptanceHistoryCriteriaBag constructor.

Parameters
string|ilTermsOfServiceEvaluableCriterion[]
Exceptions
ilTermsOfServiceUnexpectedCriteriaBagContentException

Definition at line 15 of file class.ilTermsOfServiceAcceptanceHistoryCriteriaBag.php.

16 {
17 if (is_array($data)) {
19
20 parent::__construct(array_values(array_map(function (
21 ilTermsOfServiceEvaluableCriterion $criterionAssignment
22 ) {
23 return [
24 'id' => $criterionAssignment->getCriterionId(),
25 'value' => $criterionAssignment->getCriterionValue()
26 ];
27 }, $data)));
28 } else {
30
31 if (is_string($data)) {
32 $this->fromJson($data);
33 }
34 }
35 }
Interface ilTermsOfServiceEvaluableCriterion.
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc
$data
Definition: storeScorm.php:23

References $data, ILIAS\GlobalScreen\Provider\__construct(), ensureValidArrayTypes(), fromJson(), ilTermsOfServiceEvaluableCriterion\getCriterionId(), and ilTermsOfServiceEvaluableCriterion\getCriterionValue().

+ Here is the call graph for this function:

Member Function Documentation

◆ ensureValidArrayTypes()

ilTermsOfServiceAcceptanceHistoryCriteriaBag::ensureValidArrayTypes ( array  $data)
private
Parameters
array$data

Definition at line 40 of file class.ilTermsOfServiceAcceptanceHistoryCriteriaBag.php.

40 : void
41 {
42 array_walk($data, function ($value) {
43 if (!($value instanceof ilTermsOfServiceEvaluableCriterion)) {
45 "Unexpected element found, given %s, expected instanceof '%s'",
46 var_export($value, true),
47 ilTermsOfServiceEvaluableCriterion::class
48 ));
49 }
50 });
51 }

References $data.

Referenced by __construct().

+ Here is the caller graph for this function:

◆ ensureValidInternalTypes()

ilTermsOfServiceAcceptanceHistoryCriteriaBag::ensureValidInternalTypes ( array  $data)
private
Parameters
array$data

Definition at line 56 of file class.ilTermsOfServiceAcceptanceHistoryCriteriaBag.php.

56 : void
57 {
58 array_walk($data, function ($value) {
59 if (!is_array($value)) {
61 "Unexpected element found, given %s, expected array",
62 var_export($value, true)
63 ));
64 }
65
66 if (count($value) !== 2 || !array_key_exists('id', $value) || !array_key_exists('value', $value)) {
68 "Unexpected element found, given %s, expected array with keys 'id' and 'value'",
69 var_export($value, true)
70 ));
71 }
72 });
73 }

References $data.

Referenced by fromJson().

+ Here is the caller graph for this function:

◆ fromJson()

ilTermsOfServiceAcceptanceHistoryCriteriaBag::fromJson ( string  $json)

Parameters
string$json

Exceptions
ilTermsOfServiceUnexpectedCriteriaBagContentException

Implements ilTermsOfServiceJsonDeserialization.

Definition at line 89 of file class.ilTermsOfServiceAcceptanceHistoryCriteriaBag.php.

89 : void
90 {
91 $data = json_decode($json, true);
92
93 if (!is_array($data)) {
95 "Unexpected element found, given %s, expected array",
96 var_export($data, true)
97 ));
98 }
99
101
102 $this->exchangeArray($data);
103 }

References $data, and ensureValidInternalTypes().

Referenced by __construct().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ jsonSerialize()

ilTermsOfServiceAcceptanceHistoryCriteriaBag::jsonSerialize ( )

Definition at line 108 of file class.ilTermsOfServiceAcceptanceHistoryCriteriaBag.php.

109 {
110 return $this->getArrayCopy();
111 }

◆ toJson()

ilTermsOfServiceAcceptanceHistoryCriteriaBag::toJson ( )

Implements ilTermsOfServiceJsonSerialization.

Definition at line 78 of file class.ilTermsOfServiceAcceptanceHistoryCriteriaBag.php.

78 : string
79 {
80 $json = json_encode($this);
81
82 return $json;
83 }

The documentation for this class was generated from the following file: