ILIAS  trunk Revision v11.0_alpha-1715-g7fc467680fb
All Data Structures Namespaces Files Functions Variables Enumerations Enumerator Modules Pages
Descriptive.php
Go to the documentation of this file.
1 <?php
2 
19 declare(strict_types=1);
20 
22 
23 use ILIAS\UI\Component as C;
25 
30 class Descriptive implements C\Listing\Descriptive
31 {
32  use ComponentHelper;
33 
34  private array $items;
35 
36  public function __construct(array $items)
37  {
38  $this->checkArgList(
39  "Descriptive List items",
40  $items,
41  fn ($k, $v) => is_string($k) && (is_string($v) || $v instanceof C\Component),
42  fn ($k, $v) => "expected keys of type string and values of type string|Component, got ($k => $v)"
43  );
44 
45  $this->items = $items;
46  }
47 
51  public function withItems(array $items): C\Listing\Descriptive
52  {
53  $this->checkArgList(
54  "Descriptive List items",
55  $items,
56  fn ($k, $v) => is_string($k) && (is_string($v) || $v instanceof C\Component),
57  fn ($k, $v) => "expected keys of type string and values of type string|Component, got ($k => $v)"
58  );
59 
60  $clone = clone $this;
61  $clone->items = $items;
62  return $clone;
63  }
64 
68  public function getItems(): array
69  {
70  return $this->items;
71  }
72 }