1: <?php declare(strict_types=1);
2:
3: namespace Salient\Contract\Core\Pipeline;
4:
5: use Salient\Contract\Core\Exception\InvalidDataException;
6: use Salient\Contract\HasConformity;
7:
8: /**
9: * @api
10: */
11: interface ArrayMapperInterface extends HasConformity
12: {
13: /**
14: * Remove null values from the output array
15: */
16: public const REMOVE_NULL = 1;
17:
18: /**
19: * Add unmapped values to the output array
20: */
21: public const ADD_UNMAPPED = 2;
22:
23: /**
24: * Add missing values to the output array
25: *
26: * `null` is added to the output array if the input array has no data for a
27: * given map.
28: */
29: public const ADD_MISSING = 4;
30:
31: /**
32: * Throw an exception if there are missing values
33: */
34: public const REQUIRE_MAPPED = 8;
35:
36: /**
37: * Map an input array to an output array
38: *
39: * @param mixed[] $in
40: * @return mixed[]
41: * @throws InvalidDataException if {@see REQUIRE_MAPPED} is applied and
42: * `$in` has no data for a given map.
43: */
44: public function map(array $in): array;
45: }
46: