17 if (is_array(
$data)) {
27 parent::__construct([]);
29 if (is_string(
$data)) {
41 array_walk($data,
function ($value) {
43 throw new \ilTermsOfServiceUnexpectedCriteriaBagContentException(sprintf(
44 "Unexpected element found, given %s, expected instanceof '%s'",
45 var_export($value, 1),
46 \ilTermsOfServiceEvaluableCriterion::class
57 array_walk($data,
function ($value) {
58 if (!is_array($value)) {
59 throw new \ilTermsOfServiceUnexpectedCriteriaBagContentException(sprintf(
60 "Unexpected element found, given %s, expected array",
65 if (count($value) !== 2 || !array_key_exists(
'id', $value) || !array_key_exists(
'value', $value)) {
66 throw new \ilTermsOfServiceUnexpectedCriteriaBagContentException(sprintf(
67 "Unexpected element found, given %s, expected array with keys 'id' and 'value'",
79 $json = json_encode($this);
90 $data = json_decode($json,
true);
92 if (!is_array(
$data)) {
93 throw new \ilTermsOfServiceUnexpectedCriteriaBagContentException(sprintf(
94 "Unexpected element found, given %s, expected array",
101 $this->exchangeArray(
$data);
109 return $this->getArrayCopy();
Interface ilTermsOfServiceEvaluableCriterion.
Interface ilTermsOfServiceJsonSerializable.
ensureValidArrayTypes(array $data)
Class ilTermsOfServiceAcceptanceHistoryCriteriaBag.
__construct($data=[])
ilTermsOfServiceAcceptanceHistoryCriteriaBag constructor.
ensureValidInternalTypes(array $data)