ILIAS  release_8 Revision v8.19-1-g4e8f2f9140c
All Data Structures Namespaces Files Functions Variables Modules Pages
Group.php
Go to the documentation of this file.
1 <?php
2 
3 declare(strict_types=1);
4 
22 
37 
38 class Group
39 {
41 
42  public function __construct(Factory $dataFactory)
43  {
44  $this->dataFactory = $dataFactory;
45  }
46 
51  public function string(): Transformation
52  {
53  return new StringTransformation();
54  }
55 
60  public function int(): Transformation
61  {
62  return new IntegerTransformation();
63  }
64 
69  public function float(): Transformation
70  {
71  return new FloatTransformation();
72  }
73 
78  public function bool(): Transformation
79  {
80  return new BooleanTransformation();
81  }
82 
91  public function listOf(Transformation $transformation): Transformation
92  {
93  return new ListTransformation($transformation);
94  }
95 
104  public function dictOf(Transformation $transformation): Transformation
105  {
106  return new DictionaryTransformation($transformation);
107  }
108 
123  public function tupleOf(array $transformation): Transformation
124  {
125  return new TupleTransformation($transformation);
126  }
127 
144  public function recordOf(array $transformations): Transformation
145  {
146  return new RecordTransformation($transformations);
147  }
148 
157  public function toNew($classNameOrArray): Transformation
158  {
159  if (is_array($classNameOrArray)) {
160  if (2 !== count($classNameOrArray)) {
161  throw new InvalidArgumentException('The array MUST contain exactly two elements');
162  }
163  return new NewMethodTransformation($classNameOrArray[0], $classNameOrArray[1]);
164  }
165  return new NewObjectTransformation($classNameOrArray);
166  }
167 
173  public function data(string $dataType): Transformation
174  {
175  return $this->toNew([$this->dataFactory, $dataType]);
176  }
177 
178  public function dateTime(): Transformation
179  {
180  return new DateTimeTransformation();
181  }
182 }
Factory $dataFactory
Definition: Group.php:40
toNew($classNameOrArray)
Returns either an transformation object to create objects of an existing class, with variations of co...
Definition: Group.php:157
float()
Returns an object that allows to transform a value to a float value.
Definition: Group.php:69
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
Definition: Group.php:21
recordOf(array $transformations)
Returns an object that allows to transform the values of an associative array with the given associat...
Definition: Group.php:144
__construct(Factory $dataFactory)
Definition: Group.php:42
data(string $dataType)
Definition: Group.php:173
int()
Returns an object that allows to transform a value to an integer value.
Definition: Group.php:60
dictOf(Transformation $transformation)
Returns an object that allows to transform the values of an associative array with the given transfor...
Definition: Group.php:104
Transform a string representing a datetime-value to php&#39;s DateTimeImmutable see https://www.php.net/manual/de/datetime.formats.php.
A transformation is a function from one datatype to another.
string()
Returns an object that allows to transform a value to a string value.
Definition: Group.php:51
listOf(Transformation $transformation)
Returns an object that allows to transform an value in a given array with the given transformation ob...
Definition: Group.php:91
tupleOf(array $transformation)
Returns an object that allows to transform the values of an array with the given array of transformat...
Definition: Group.php:123
bool()
Returns an object that allows to transform a value to a boolean value.
Definition: Group.php:78