ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
ILIAS\LegalDocuments\Map Class Reference
+ Collaboration diagram for ILIAS\LegalDocuments\Map:

Public Member Functions

 __construct (private readonly array $map=[],)
 
 add (string $name, $item)
 
 set (string $name, string $key, $item)
 
 has (string $name, string $key)
 
 append (self $other)
 
 value ()
 

Private Member Functions

 map (string $key, Closure $proc)
 

Detailed Description

Definition at line 26 of file Map.php.

Constructor & Destructor Documentation

◆ __construct()

ILIAS\LegalDocuments\Map::__construct ( private readonly array  $map = [])
Parameters
array<string,list|array<string,mixed>>$map

Definition at line 31 of file Map.php.

33 {
34 }

Member Function Documentation

◆ add()

ILIAS\LegalDocuments\Map::add ( string  $name,
  $item 
)

Definition at line 36 of file Map.php.

36 : static
37 {
38 return $this->map($name, fn($list) => [...$list, $item]);
39 }
map(string $key, Closure $proc)
Definition: Map.php:71

References ILIAS\LegalDocuments\Map\map().

Referenced by ILIAS\LegalDocuments\Wiring\addTo().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ append()

ILIAS\LegalDocuments\Map::append ( self  $other)

Definition at line 51 of file Map.php.

51 : self
52 {
53 array_map(function ($mine, $other) {
54 $mine ??= [];
55 $other ??= [];
56 if (count($mine) + count($other) !== count(array_merge($mine, $other))) {
57 throw new Exception('Cannot append maps. Keys must be distinct.');
58 }
59 }, $this->map, $other->value());
60 return new self(array_merge_recursive($this->map, $other->value()));
61 }

References ILIAS\LegalDocuments\Map\map().

+ Here is the call graph for this function:

◆ has()

ILIAS\LegalDocuments\Map::has ( string  $name,
string  $key 
)

Definition at line 46 of file Map.php.

46 : bool
47 {
48 return isset($this->map[$name][$key]);
49 }

References ILIAS\LegalDocuments\Map\map().

+ Here is the call graph for this function:

◆ map()

ILIAS\LegalDocuments\Map::map ( string  $key,
Closure  $proc 
)
private
Parameters
Closure(array)array $proc

Definition at line 71 of file Map.php.

71 : static
72 {
73 return new self([...$this->map, $key => $proc($this->map[$key] ?? [])]);
74 }

References ILIAS\LegalDocuments\Map\map().

Referenced by ILIAS\LegalDocuments\Map\add(), ILIAS\LegalDocuments\Map\append(), ILIAS\LegalDocuments\Map\has(), ILIAS\LegalDocuments\Map\map(), and ILIAS\LegalDocuments\Map\set().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ set()

ILIAS\LegalDocuments\Map::set ( string  $name,
string  $key,
  $item 
)

Definition at line 41 of file Map.php.

41 : static
42 {
43 return $this->map($name, fn(array $map) => [...$map, $key => $item]);
44 }

References ILIAS\LegalDocuments\Map\map().

Referenced by ILIAS\LegalDocuments\Wiring\addTo().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ value()

ILIAS\LegalDocuments\Map::value ( )

Definition at line 63 of file Map.php.

63 : array
64 {
65 return $this->map;
66 }

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