ILIAS  trunk Revision v11.0_alpha-2658-ge2404539063
ILIAS\Data\Description\DMap Class Reference
+ Inheritance diagram for ILIAS\Data\Description\DMap:
+ Collaboration diagram for ILIAS\Data\Description\DMap:

Public Member Functions

 __construct (Text\SimpleDocumentMarkdown $description, protected DValue $key_type, protected Description $value_type)
 
 getPrimitiveRepresentation (mixed $data)
 
 getKeyType ()
 
 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 DMap.php.

Constructor & Destructor Documentation

◆ __construct()

ILIAS\Data\Description\DMap::__construct ( Text\SimpleDocumentMarkdown  $description,
protected DValue  $key_type,
protected Description  $value_type 
)

Definition at line 29 of file DMap.php.

References ILIAS\GlobalScreen\Provider\__construct().

33  {
34  parent::__construct($description);
35  }
__construct(Container $dic, ilPlugin $plugin)
+ Here is the call graph for this function:

Member Function Documentation

◆ getKeyType()

ILIAS\Data\Description\DMap::getKeyType ( )

Definition at line 72 of file DMap.php.

72  : DValue
73  {
74  return $this->key_type;
75  }

◆ getPrimitiveRepresentation()

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

Definition at line 37 of file DMap.php.

37  : mixed
38  {
39  if (!is_array($data)) {
40  return fn() => yield "Expected an array.";
41  }
42 
43  $repr = [];
44  $errors = [];
45 
46  foreach ($data as $k => $v) {
47  $key = $this->key_type->getPrimitiveRepresentation($k);
48  $value = $this->value_type->getPrimitiveRepresentation($v);
49 
50  $key_is_error = $key instanceof \Closure;
51  $value_is_error = $value instanceof \Closure;
52 
53  if ($key_is_error) {
54  $errors[] = $key;
55  }
56  if ($value_is_error) {
57  $errors[] = $value;
58  }
59 
60  if (!$key_is_error && !$value_is_error) {
61  $repr[$key] = $value;
62  }
63  }
64 
65  if ($errors) {
66  return $this->mergeErrors($errors);
67  }
68 
69  return $repr;
70  }

◆ getValueType()

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

Definition at line 77 of file DMap.php.

77  : Description
78  {
79  return $this->value_type;
80  }

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