ILIAS  release_7 Revision v7.30-3-g800a261c036
Group.php
Go to the documentation of this file.
1<?php
2declare(strict_types=1);
3
4/* Copyright (c) 1998-2019 ILIAS open source, Extended GPL, see docs/LICENSE */
5
11
24
25class Group
26{
30 private $dataFactory;
31
35 public function __construct(\ILIAS\Data\Factory $dataFactory)
36 {
37 $this->dataFactory = $dataFactory;
38 }
39
45 public function string() : StringTransformation
46 {
47 return new StringTransformation();
48 }
49
55 public function int() : IntegerTransformation
56 {
57 return new IntegerTransformation();
58 }
59
65 public function float() : FloatTransformation
66 {
67 return new FloatTransformation();
68 }
69
75 public function bool() : BooleanTransformation
76 {
77 return new BooleanTransformation();
78 }
79
91 public function listOf(Transformation $transformation) : Transformation
92 {
93 return new ListTransformation($transformation);
94 }
95
107 public function dictOf(Transformation $transformation) : Transformation
108 {
109 return new DictionaryTransformation($transformation);
110 }
111
127 public function tupleOf(array $transformation) : Transformation
128 {
129 return new TupleTransformation($transformation);
130 }
131
149 public function recordOf(array $transformations) : Transformation
150 {
151 return new RecordTransformation($transformations);
152 }
153
163 public function toNew($classNameOrArray) : Transformation
164 {
165 if (is_array($classNameOrArray)) {
166 if (2 !== count($classNameOrArray)) {
167 throw new \InvalidArgumentException('The array MUST contain exactly two elements');
168 }
169 return new NewMethodTransformation($classNameOrArray[0], $classNameOrArray[1]);
170 }
171 return new NewObjectTransformation($classNameOrArray);
172 }
173
179 public function data(string $dataType) : Transformation
180 {
181 return $this->toNew(array($this->dataFactory, $dataType));
182 }
183
184
186 {
187 return new DateTimeTransformation($this->dataFactory);
188 }
189}
An exception for terminatinating execution or to throw for unit testing.
Builds data types.
Definition: Factory.php:20
int()
Returns an object that allows to transform a value to an integer value.
Definition: Group.php:55
bool()
Returns an object that allows to transform a value to a boolean value.
Definition: Group.php:75
string()
Returns an object that allows to transform a value to a string value.
Definition: Group.php:45
data(string $dataType)
Definition: Group.php:179
recordOf(array $transformations)
Returns an object that allows to transform the values of an associative array with the given associat...
Definition: Group.php:149
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
float()
Returns an object that allows to transform a value to a float value.
Definition: Group.php:65
__construct(\ILIAS\Data\Factory $dataFactory)
Definition: Group.php:35
toNew($classNameOrArray)
Returns either an transformation object to create objects of an existing class, with variations of co...
Definition: Group.php:163
tupleOf(array $transformation)
Returns an object that allows to transform the values of an array with the given array of transformat...
Definition: Group.php:127
dictOf(Transformation $transformation)
Returns an object that allows to transform the values of an associative array with the given transfor...
Definition: Group.php:107
Transform a string representing a datetime-value to php's DateTimeImmutable see https://www....
A transformation is a function from one datatype to another.
Class ChatMainBarProvider \MainMenu\Provider.