mirror of
https://github.com/danog/Valinor.git
synced 2024-11-30 04:39:05 +01:00
6d427088f7
The method `MapperBuilder::bind()` can be used to define a custom way to build an object during the mapping. The return type of the callback will be resolved by the mapping to know when to use it. The callback can take any arguments, that will automatically be mapped using the given source. These arguments can then be used to instantiate the object in the desired way. Example: ```php (new \CuyZ\Valinor\MapperBuilder()) ->bind(function(string $string, OtherClass $otherClass): SomeClass { $someClass = new SomeClass($string); $someClass->addOtherClass($otherClass); return $someClass; }) ->mapper() ->map(SomeClass::class, [ // … ]); ``` |
||
---|---|---|
.. | ||
Fake | ||
Fixture | ||
Functional | ||
Integration | ||
StaticAnalysis | ||
Traits | ||
Unit |