ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
ILIAS\Data\Description\DList Class Reference
+ Inheritance diagram for ILIAS\Data\Description\DList:
+ Collaboration diagram for ILIAS\Data\Description\DList:

Public Member Functions

 __construct (Text\SimpleDocumentMarkdown $description, protected Description $value_type)
 
 getPrimitiveRepresentation (mixed $data)
 Each of the types that can be described has a canonical representation created from primitive PHP types. More...
 
 getValueType ()
 
- Public Member Functions inherited from ILIAS\Data\Description\Description
 __construct (protected ?Text\SimpleDocumentMarkdown $description,)
 
 getDescription ()
 
 getPrimitiveRepresentation (mixed $data)
 Each of the types that can be described has a canonical representation created from primitive PHP types. More...
 
 matches (mixed $data)
 

Detailed Description

Definition at line 25 of file DList.php.

Constructor & Destructor Documentation

◆ __construct()

ILIAS\Data\Description\DList::__construct ( Text\SimpleDocumentMarkdown  $description,
protected Description  $value_type 
)

Definition at line 29 of file DList.php.

32 {
33 parent::__construct($description);
34 }
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc

References ILIAS\GlobalScreen\Provider\__construct().

+ Here is the call graph for this function:

Member Function Documentation

◆ getPrimitiveRepresentation()

ILIAS\Data\Description\DList::getPrimitiveRepresentation ( mixed  $data)

Each of the types that can be described has a canonical representation created from primitive PHP types.

This attempts to transform the provided data into such a representation.

If this returns a \Closure, the data cannot be transformed into such a representation and the \Closure will produce a generator that provides a list of defects where $data does not match the description. If this does return something else it will be plain old php data according to the description.

Reimplemented from ILIAS\Data\Description\Description.

Definition at line 36 of file DList.php.

36 : mixed
37 {
38 if (!is_array($data)) {
39 return fn() => yield "Expected an array.";
40 }
41
42 $repr = [];
43 $errors = [];
44
45 foreach ($data as $v) {
46 $value = $this->value_type->getPrimitiveRepresentation($v);
47
48 if ($value instanceof \Closure) {
49 $errors[] = $value;
50 } else {
51 $repr[] = $value;
52 }
53 }
54
55 if ($errors) {
56 return $this->mergeErrors($errors);
57 }
58
59 return $repr;
60 }

References $data.

◆ getValueType()

ILIAS\Data\Description\DList::getValueType ( )

Definition at line 62 of file DList.php.

63 {
64 return $this->value_type;
65 }
This describes some datastructure in terms of standard data structures such as primitives,...
Definition: Description.php:33

The documentation for this class was generated from the following file: