1 | <?php |
||
14 | class Engine |
||
15 | { |
||
16 | /** |
||
17 | * @var Internal\Configuration |
||
18 | */ |
||
19 | private $config; |
||
20 | |||
21 | public function __construct() |
||
25 | |||
26 | /** |
||
27 | * Returns mapping options |
||
28 | * |
||
29 | * @return MappingOptionsInterface |
||
30 | */ |
||
31 | public function getMappingOptions() |
||
35 | |||
36 | /** |
||
37 | * Creates a TypeMap for the source's type and destination's type. |
||
38 | * |
||
39 | * @param string $sourceType Source type |
||
40 | * @param string $destinationType Destination type |
||
41 | * @throws ClassNotFoundException |
||
42 | * @return MappingFluentSyntax |
||
43 | */ |
||
44 | public function createMap($sourceType, $destinationType) |
||
48 | |||
49 | /** |
||
50 | * Configure map |
||
51 | * |
||
52 | * @param MappingConfigurationInterface $configuration |
||
53 | */ |
||
54 | public function configureMapping(MappingConfigurationInterface $configuration) |
||
58 | |||
59 | /** |
||
60 | * Initialize a mapping from the source object. |
||
61 | * The source type can be is inferred from the source object. |
||
62 | * |
||
63 | * @param object|object[] $source Source object or collection to map from |
||
64 | * @param string|null $sourceType Source object type |
||
65 | * @throws MappingException |
||
66 | * @return ExecuteMappingFluentSyntax |
||
67 | */ |
||
68 | public function map($source, $sourceType = null) |
||
72 | |||
73 | /** |
||
74 | * Execute a mapping using MappingContext |
||
75 | * |
||
76 | * @param MappingContext $context Mapping context |
||
77 | * @return object|object[] Mapped destination object or collection |
||
78 | * @throws MappingException |
||
79 | * @throws ClassNotFoundException |
||
80 | */ |
||
81 | public function execute(MappingContext $context) |
||
98 | |||
99 | /** |
||
100 | * Validates that every top level destination property is mapped to source property. |
||
101 | * If not, a ConfigurationException is thrown detailing any missing mappings. |
||
102 | * |
||
103 | * @throws ValidationException if any TypeMaps contain unmapped properties |
||
104 | */ |
||
105 | public function validate() |
||
120 | |||
121 | /** |
||
122 | * Clear out all existing configuration |
||
123 | */ |
||
124 | public function reset() |
||
128 | |||
129 | private function mapCollection(MappingContext $context, \Closure $mapFunc) |
||
137 | |||
138 | private function mapObject(MappingContext $context, \Closure $mapFunc) |
||
142 | } |
||
143 |
Our type inference engine in quite powerful, but sometimes the code does not provide enough clues to go by. In these cases we request you to add a
@return
annotation as described here.