ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
Factory.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
21namespace ILIAS\Refinery;
22
23use ILIAS\Refinery\Random\Group as RandomGroup;
24
26{
27 private \ILIAS\Data\Factory $dataFactory;
28 private \ILIAS\Language\Language $language;
29
30 public function __construct(\ILIAS\Data\Factory $dataFactory, \ILIAS\Language\Language $language)
31 {
32 $this->dataFactory = $dataFactory;
33 $this->language = $language;
34 }
35
40 public function to(): To\Group
41 {
42 $this->loadLanguageModules();
43 return new To\Group($this->dataFactory, $this->language);
44 }
45
55 public function kindlyTo(): KindlyTo\Group
56 {
57 return new KindlyTo\Group($this->dataFactory);
58 }
59
65 public function in(): In\Group
66 {
67 return new In\Group();
68 }
69
74 public function int(): Integer\Group
75 {
76 $this->loadLanguageModules();
77 return new Integer\Group($this->dataFactory, $this->language, $this->in());
78 }
79
83 public function string(): String\Group
84 {
85 $this->loadLanguageModules();
86 return new String\Group($this->dataFactory, $this->language);
87 }
88
92 public function custom(): Custom\Group
93 {
94 $this->language->loadLanguageModule('validation');
95 return new Custom\Group($this->dataFactory, $this->language);
96 }
97
101 public function container(): Container\Group
102 {
103 $this->loadLanguageModules();
104 return new Container\Group($this->dataFactory);
105 }
106
110 public function password(): Password\Group
111 {
112 $this->loadLanguageModules();
113 return new Password\Group($this->dataFactory, $this->language);
114 }
115
119 public function logical(): Logical\Group
120 {
121 $this->loadLanguageModules();
122 return new Logical\Group($this->dataFactory, $this->language);
123 }
124
128 public function null(): Constraint
129 {
130 $this->loadLanguageModules();
131 return new IsNull($this->dataFactory, $this->language);
132 }
133
137 public function numeric(): Numeric\Group
138 {
139 $this->loadLanguageModules();
140 return new Numeric\Group($this->dataFactory, $this->language);
141 }
142
146 public function dateTime(): DateTime\Group
147 {
148 return new DateTime\Group();
149 }
150
154 public function uri(): URI\Group
155 {
156 return new URI\Group();
157 }
158
159 public function encode(): Encode\Group
160 {
161 return new Encode\Group();
162 }
163
168 public function byTrying(array $transformations): ByTrying
169 {
170 $this->loadLanguageModules();
171 return new ByTrying($transformations, $this->dataFactory, $this->language);
172 }
173
174 public function random(): RandomGroup
175 {
176 return new RandomGroup();
177 }
178
179 public function identity(): Transformation
180 {
181 return new IdentityTransformation();
182 }
183
184 public function always($value): Transformation
185 {
186 return new ConstantTransformation($value);
187 }
188
189 public function executable(): Transformation
190 {
191 $this->loadLanguageModules();
192 return new IsExecutableTransformation($this->language);
193 }
194
195 protected function loadLanguageModules(): void
196 {
197 $this->language->loadLanguageModule('validation');
198 }
199}
Builds data types.
Definition: Factory.php:36
A password is used as part of credentials for authentication.
Definition: Password.php:31
The scope of this class is split ilias-conform URI's into components.
Definition: URI.php:35
container()
Contains constraints for container types (e.g.
Definition: Factory.php:101
custom()
Contains constraints and transformations for custom functions.
Definition: Factory.php:92
ILIAS Language Language $language
Definition: Factory.php:28
int()
Contains constraints and transformations on numbers.
Definition: Factory.php:74
password()
Contains constraints for password strings.
Definition: Factory.php:110
logical()
Contains constraints for logical compositions with other constraints.
Definition: Factory.php:119
in()
Creates a factory object to create a transformation object, that can be used to execute other transfo...
Definition: Factory.php:65
uri()
Contains transformations for Data\URI.
Definition: Factory.php:154
numeric()
Contains constraints for numeric data types.
Definition: Factory.php:137
byTrying(array $transformations)
Accepts Transformations and uses first successful one.
Definition: Factory.php:168
__construct(\ILIAS\Data\Factory $dataFactory, \ILIAS\Language\Language $language)
Definition: Factory.php:30
string()
Contains constraints for string.
Definition: Factory.php:83
kindlyTo()
Combined validations and transformations for primitive data types that establish a baseline for furth...
Definition: Factory.php:55
to()
Combined validations and transformations for primitive data types that establish a baseline for furth...
Definition: Factory.php:40
ILIAS Data Factory $dataFactory
Definition: Factory.php:27
dateTime()
Contains transformations for DateTime.
Definition: Factory.php:146
Validates that the given string is a valid and executable file path.
A constraint encodes some resrtictions on values.
Definition: Constraint.php:32
A transformation is a function from one datatype to another.
Interface Observer \BackgroundTasks Contains several chained tasks and infos about them.