ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
Descriptive.php
Go to the documentation of this file.
1<?php
2
3/* Copyright (c) 2016 Timon Amstutz <timon.amstutz@ilub.unibe.ch> Extended GPL, see docs/LICENSE */
4
6
9
15{
17
21 private $items;
22
26 public function __construct(array $items)
27 {
28 $this->checkArgList(
29 "Descriptive List items",
30 $items,
31 function ($k, $v) {
32 return is_string($k) && (is_string($v) || $v instanceof C\Component);
33 },
34 function ($k, $v) {
35 return "expected keys of type string and values of type string|Component, got ($k => $v)";
36 }
37 );
38
39 $this->items = $items;
40 }
41
45 public function withItems(array $items)
46 {
47 $this->checkArgList(
48 "Descriptive List items",
49 $items,
50 function ($k, $v) {
51 return is_string($k) && (is_string($v) || $v instanceof C\Component);
52 },
53 function ($k, $v) {
54 return "expected keys of type string and values of type string|Component, got ($k => $v)";
55 }
56 );
57
58 $clone = clone $this;
59 $clone->items = $items;
60 return $clone;
61 }
62
66 public function getItems()
67 {
68 return $this->items;
69 }
70}
An exception for terminatinating execution or to throw for unit testing.
A component is the most general form of an entity in the UI.
Definition: Component.php:14
checkArgList($which, array &$values, \Closure $check, \Closure $message)
Check every key and value of the list with a supplied closure.
trait ComponentHelper
Provides common functionality for component implementations.