-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathAutoMapper.php
260 lines (214 loc) · 8.8 KB
/
AutoMapper.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
<?php declare(strict_types=1);
namespace Acelot\AutoMapper;
use Acelot\AutoMapper\Api\Fields;
use Acelot\AutoMapper\Api\Helpers;
use Acelot\AutoMapper\Api\Main;
use Acelot\AutoMapper\Api\Processors;
use Acelot\AutoMapper\Field\ToArrayKey;
use Acelot\AutoMapper\Field\ToObjectMethod;
use Acelot\AutoMapper\Field\ToObjectProp;
use Acelot\AutoMapper\Field\ToSelf;
use Acelot\AutoMapper\Integrations\RespectValidation\Api\Validation;
use Acelot\AutoMapper\Integrations\RespectValidation\Processor\Validate;
use Acelot\AutoMapper\Processor\AssertType;
use Acelot\AutoMapper\Processor\Call;
use Acelot\AutoMapper\Processor\CallWithContext;
use Acelot\AutoMapper\Processor\Condition;
use Acelot\AutoMapper\Processor\ConditionWithContext;
use Acelot\AutoMapper\Processor\Find;
use Acelot\AutoMapper\Processor\FindWithContext;
use Acelot\AutoMapper\Processor\Get;
use Acelot\AutoMapper\Processor\GetFromContext;
use Acelot\AutoMapper\Processor\Ignore;
use Acelot\AutoMapper\Processor\MapIterable;
use Acelot\AutoMapper\Processor\MarshalNestedArray;
use Acelot\AutoMapper\Processor\MarshalNestedObject;
use Acelot\AutoMapper\Processor\NotFound;
use Acelot\AutoMapper\Processor\Pass;
use Acelot\AutoMapper\Processor\Pipeline;
use Acelot\AutoMapper\Processor\Value;
use Respect\Validation\Validatable;
use stdClass;
/**
* @generated AUTOGENERATED FILE, DO NOT TOUCH, USE `make build` TO UPDATE
*/
final class AutoMapper
{
private static array $instances = array();
public static function map(ContextInterface $context, mixed $source, mixed &$target, FieldInterface ...$fields): void
{
self::getInstance(Main::class)->map($context, $source, $target, ...$fields);
}
public static function marshalArray(ContextInterface $context, mixed $source, ToArrayKey ...$fields): array
{
return self::getInstance(Main::class)->marshalArray($context, $source, ...$fields);
}
public static function marshalObject(ContextInterface $context, mixed $source, ObjectFieldInterface ...$fields): stdClass
{
return self::getInstance(Main::class)->marshalObject($context, $source, ...$fields);
}
public static function toKey(int|string $key, ProcessorInterface $processor): ToArrayKey
{
return self::getInstance(Fields::class)->toKey($key, $processor);
}
public static function toProp(string $property, ProcessorInterface $processor): ToObjectProp
{
return self::getInstance(Fields::class)->toProp($property, $processor);
}
public static function toMethod(string $method, ProcessorInterface $processor): ToObjectMethod
{
return self::getInstance(Fields::class)->toMethod($method, $processor);
}
public static function toSelf(ProcessorInterface $processor): ToSelf
{
return self::getInstance(Fields::class)->toSelf($processor);
}
public static function assertType(string $oneOfType, string ...$oneOfTypes): AssertType
{
return self::getInstance(Processors::class)->assertType($oneOfType, ...$oneOfTypes);
}
public static function call(callable $callable): Call
{
return self::getInstance(Processors::class)->call($callable);
}
public static function callCtx(callable $callable): CallWithContext
{
return self::getInstance(Processors::class)->callCtx($callable);
}
public static function condition(callable $condition, ProcessorInterface $true, ?ProcessorInterface $false = null): Condition
{
return self::getInstance(Processors::class)->condition($condition, $true, $false);
}
public static function conditionCtx(callable $condition, ProcessorInterface $true, ?ProcessorInterface $false = null): ConditionWithContext
{
return self::getInstance(Processors::class)->conditionCtx($condition, $true, $false);
}
public static function find(callable $predicate): Find
{
return self::getInstance(Processors::class)->find($predicate);
}
public static function findCtx(callable $predicate): FindWithContext
{
return self::getInstance(Processors::class)->findCtx($predicate);
}
public static function get(string $path): Get
{
return self::getInstance(Processors::class)->get($path);
}
public static function getFromCtx(string $key): GetFromContext
{
return self::getInstance(Processors::class)->getFromCtx($key);
}
public static function ignore(): Ignore
{
return self::getInstance(Processors::class)->ignore();
}
public static function mapIterable(ProcessorInterface $processor, bool $keepKeys = false): MapIterable
{
return self::getInstance(Processors::class)->mapIterable($processor, $keepKeys);
}
public static function marshalNestedArray(ToArrayKey $firstField, ToArrayKey ...$restFields): MarshalNestedArray
{
return self::getInstance(Processors::class)->marshalNestedArray($firstField, ...$restFields);
}
public static function marshalNestedObject(ToObjectProp $firstField, ToObjectProp ...$restFields): MarshalNestedObject
{
return self::getInstance(Processors::class)->marshalNestedObject($firstField, ...$restFields);
}
public static function notFound(string $path): NotFound
{
return self::getInstance(Processors::class)->notFound($path);
}
public static function value(mixed $value): Value
{
return self::getInstance(Processors::class)->value($value);
}
public static function pass(): Pass
{
return self::getInstance(Processors::class)->pass();
}
public static function pipe(ProcessorInterface ...$processors): Pipeline
{
return self::getInstance(Processors::class)->pipe(...$processors);
}
public static function joinArray(string $separator = ''): Pipeline
{
return self::getInstance(Helpers::class)->joinArray($separator);
}
public static function sortArray(bool $descending = false, int $options = SORT_REGULAR): Pipeline
{
return self::getInstance(Helpers::class)->sortArray($descending, $options);
}
public static function uniqueArray(bool $keepKeys = false, int $options = SORT_STRING): Pipeline
{
return self::getInstance(Helpers::class)->uniqueArray($keepKeys, $options);
}
public static function ifNotFound(ProcessorInterface $true, ?ProcessorInterface $false = null): Condition
{
return self::getInstance(Helpers::class)->ifNotFound($true, $false);
}
public static function ifEmpty(ProcessorInterface $true, ?ProcessorInterface $false = null): Condition
{
return self::getInstance(Helpers::class)->ifEmpty($true, $false);
}
public static function ifNull(ProcessorInterface $true, ?ProcessorInterface $false = null): Condition
{
return self::getInstance(Helpers::class)->ifNull($true, $false);
}
public static function ifEqual(mixed $to, ProcessorInterface $true, ?ProcessorInterface $false = null, bool $strict = true): Condition
{
return self::getInstance(Helpers::class)->ifEqual($to, $true, $false, $strict);
}
public static function ifNotEqual(mixed $to, ProcessorInterface $true, ?ProcessorInterface $false = null, bool $strict = true): Condition
{
return self::getInstance(Helpers::class)->ifNotEqual($to, $true, $false, $strict);
}
public static function explodeString(string $separator): Pipeline
{
return self::getInstance(Helpers::class)->explodeString($separator);
}
public static function trimString(string $characters = " \t\n\r\x00\v"): Pipeline
{
return self::getInstance(Helpers::class)->trimString($characters);
}
public static function toBool(): Call
{
return self::getInstance(Helpers::class)->toBool();
}
public static function toFloat(): Pipeline
{
return self::getInstance(Helpers::class)->toFloat();
}
public static function toInt(): Pipeline
{
return self::getInstance(Helpers::class)->toInt();
}
public static function toString(): Pipeline
{
return self::getInstance(Helpers::class)->toString();
}
public static function toArray(): Call
{
return self::getInstance(Helpers::class)->toArray();
}
public static function validate(Validatable $validator): Validate
{
return self::getInstance(Validation::class)->validate($validator);
}
public static function ifValidationFailed(ProcessorInterface $true, ?ProcessorInterface $false = null): Condition
{
return self::getInstance(Validation::class)->ifValidationFailed($true, $false);
}
/**
* @template T
* @param class-string<T> $class
* @return T
*/
private static function getInstance(string $class)
{
if (!isset(self::$instances[$class])) {
self::$instances[$class] = new $class();
}
return self::$instances[$class];
}
}