ILIAS  release_8 Revision v8.24
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)
 
 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[]$data
Exceptions
ilTermsOfServiceUnexpectedCriteriaBagContentException

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

33 {
34 if (is_array($data)) {
36
37 parent::__construct(array_values(array_map(static function (
38 ilTermsOfServiceEvaluableCriterion $criterionAssignment
39 ): array {
40 return [
41 'id' => $criterionAssignment->getCriterionId(),
42 'value' => $criterionAssignment->getCriterionValue()
43 ];
44 }, $data)));
45 } else {
47
48 if (is_string($data)) {
49 $this->fromJson($data);
50 }
51 }
52 }
Interface ilTermsOfServiceEvaluableCriterion.
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc

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

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

54 : void
55 {
56 array_walk($data, static function ($value): void {
57 if (!($value instanceof ilTermsOfServiceEvaluableCriterion)) {
59 "Unexpected element found, given %s, expected instanceof '%s'",
60 var_export($value, true),
61 ilTermsOfServiceEvaluableCriterion::class
62 ));
63 }
64 });
65 }

References $data.

Referenced by __construct().

+ Here is the caller graph for this function:

◆ ensureValidInternalTypes()

ilTermsOfServiceAcceptanceHistoryCriteriaBag::ensureValidInternalTypes ( array  $data)
private

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

67 : void
68 {
69 array_walk($data, static function ($value): void {
70 if (!is_array($value)) {
72 'Unexpected element found, given %s, expected array',
73 var_export($value, true)
74 ));
75 }
76
77 if (!array_key_exists('id', $value) || !array_key_exists('value', $value) || count($value) !== 2) {
79 "Unexpected element found, given %s, expected array with keys 'id' and 'value'",
80 var_export($value, true)
81 ));
82 }
83 });
84 }

References $data.

Referenced by fromJson().

+ Here is the caller graph for this function:

◆ fromJson()

ilTermsOfServiceAcceptanceHistoryCriteriaBag::fromJson ( string  $json)

Exceptions
ilTermsOfServiceUnexpectedCriteriaBagContentException

Implements ilTermsOfServiceJsonDeserialization.

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

95 : void
96 {
97 $data = json_decode($json, true, 512, JSON_THROW_ON_ERROR);
98
99 if (!is_array($data)) {
101 'Unexpected element found, given %s, expected array',
102 var_export($data, true)
103 ));
104 }
105
107
108 $this->exchangeArray($data);
109 }

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 111 of file class.ilTermsOfServiceAcceptanceHistoryCriteriaBag.php.

111 : array
112 {
113 return $this->getArrayCopy();
114 }

◆ toJson()

ilTermsOfServiceAcceptanceHistoryCriteriaBag::toJson ( )

Implements ilTermsOfServiceJsonSerialization.

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

86 : string
87 {
88 return json_encode($this, JSON_THROW_ON_ERROR);
89 }

Referenced by ilTermsOfServiceAcceptanceHistoryCriteriaBagTest\testCriteriaCanBePassedAsString().

+ Here is the caller graph for this function:

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