ILIAS  release_6 Revision v6.24-5-g0c8bfefb3b8
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 ()
 

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.

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

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  }
$data
Definition: storeScorm.php:23
Interface ilTermsOfServiceEvaluableCriterion.
__construct(Container $dic, ilPlugin $plugin)
+ 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.

Referenced by __construct().

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  }
$data
Definition: storeScorm.php:23
Interface ilTermsOfServiceEvaluableCriterion.
+ 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.

Referenced by fromJson().

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  }
$data
Definition: storeScorm.php:23
+ 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.

References $data, and ensureValidInternalTypes().

Referenced by __construct().

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  }
$data
Definition: storeScorm.php:23
+ 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: