ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
ArrayArtifact.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
22
23use ILIAS\Setup;
24
29{
30 private array $data = [];
31
35 public function __construct(array $data)
36 {
37 $this->check($data);
38 $this->data = $data;
39 }
40
41
42 final public function serialize(): string
43 {
44 return "<?" . "php return " . var_export($this->data, true) . ";";
45 }
46
47 private function check(array $a): void
48 {
49 foreach ($a as $item) {
50 if (is_string($item) || is_int($item) || is_float($item) || is_bool($item) || is_null($item)) {
51 continue;
52 }
53 if (is_array($item)) {
54 $this->check($item);
55 continue;
56 }
57 throw new \InvalidArgumentException(
58 "Array data for artifact may only contain ints, strings, floats, bools or " .
59 "other arrays with this content. Found: " . gettype($item)
60 );
61 }
62 }
63}
An array as an artifact.
serialize()
This method will be called from the source, which wants to save the artifact.
An artifact is some file that is build on demand per installation and is not shipped with the ILIAS s...
Definition: Artifact.php:28
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
$a
thx to https://mlocati.github.io/php-cs-fixer-configurator for the examples