ILIAS  release_8 Revision v8.19
All Data Structures Namespaces Files Functions Variables Modules Pages
ILIAS\Refinery\KeyValueAccess Class Reference
+ Inheritance diagram for ILIAS\Refinery\KeyValueAccess:
+ Collaboration diagram for ILIAS\Refinery\KeyValueAccess:

Public Member Functions

 __construct (array $raw_values, Transformation $trafo)
 
 offsetExists ($offset)
 
 offsetGet ($offset)
 
 offsetSet ($offset, $value)
 
 offsetUnset ($offset)
 
 count ()
 

Private Member Functions

 getApplicator ()
 

Private Attributes

array $raw_values
 
Transformation $trafo
 

Detailed Description

Definition at line 27 of file KeyValueAccess.php.

Constructor & Destructor Documentation

◆ __construct()

ILIAS\Refinery\KeyValueAccess::__construct ( array  $raw_values,
Transformation  $trafo 
)

Definition at line 32 of file KeyValueAccess.php.

References ILIAS\Refinery\KeyValueAccess\$raw_values, and ILIAS\Refinery\KeyValueAccess\$trafo.

33  {
34  $this->trafo = $trafo;
35  $this->raw_values = $raw_values;
36  }

Member Function Documentation

◆ count()

ILIAS\Refinery\KeyValueAccess::count ( )

Definition at line 94 of file KeyValueAccess.php.

94  : int
95  {
96  return count($this->raw_values);
97  }

◆ getApplicator()

ILIAS\Refinery\KeyValueAccess::getApplicator ( )
private

Definition at line 60 of file KeyValueAccess.php.

Referenced by ILIAS\Refinery\KeyValueAccess\offsetGet().

60  : Closure
61  {
62  return function ($value) {
63  if (is_array($value)) {
64  foreach ($value as $k => $v) {
65  $value[$k] = $this->getApplicator()($v);
66  }
67  return $value;
68  }
69  return $this->trafo->transform($value);
70  };
71  }
+ Here is the caller graph for this function:

◆ offsetExists()

ILIAS\Refinery\KeyValueAccess::offsetExists (   $offset)

Definition at line 41 of file KeyValueAccess.php.

Referenced by ILIAS\Refinery\KeyValueAccess\offsetGet(), and ILIAS\Refinery\KeyValueAccess\offsetUnset().

41  : bool
42  {
43  return isset($this->raw_values[$offset]);
44  }
+ Here is the caller graph for this function:

◆ offsetGet()

ILIAS\Refinery\KeyValueAccess::offsetGet (   $offset)

Definition at line 49 of file KeyValueAccess.php.

References ILIAS\Refinery\KeyValueAccess\getApplicator(), and ILIAS\Refinery\KeyValueAccess\offsetExists().

50  {
51  if (!$this->offsetExists($offset)) {
52  return null;
53  }
54 
55  return is_array($this->raw_values[$offset])
56  ? array_map($this->getApplicator(), $this->raw_values[$offset])
57  : $this->getApplicator()($this->raw_values[$offset]);
58  }
+ Here is the call graph for this function:

◆ offsetSet()

ILIAS\Refinery\KeyValueAccess::offsetSet (   $offset,
  $value 
)

Definition at line 76 of file KeyValueAccess.php.

76  : void
77  {
78  $this->raw_values[$offset] = $value;
79  }

◆ offsetUnset()

ILIAS\Refinery\KeyValueAccess::offsetUnset (   $offset)

Definition at line 84 of file KeyValueAccess.php.

References ILIAS\Refinery\KeyValueAccess\offsetExists().

84  : void
85  {
86  if ($this->offsetExists($offset)) {
87  unset($this->raw_values[$offset]);
88  }
89  }
+ Here is the call graph for this function:

Field Documentation

◆ $raw_values

array ILIAS\Refinery\KeyValueAccess::$raw_values
private

Definition at line 29 of file KeyValueAccess.php.

Referenced by ILIAS\Refinery\KeyValueAccess\__construct().

◆ $trafo

Transformation ILIAS\Refinery\KeyValueAccess::$trafo
private

Definition at line 30 of file KeyValueAccess.php.

Referenced by ILIAS\Refinery\KeyValueAccess\__construct().


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