/** * Supply a custom instantiation function for the destination type * * @param ObjectCreatorInterface|\Closure $objectCreator Callback to create the destination type given the source object * @throws PapperConfigurationException * @return MappingFluentSyntax */ public function constructUsing($objectCreator) { if ($objectCreator instanceof \Closure) { $objectCreator = new ClosureObjectCreator($objectCreator); } if (!$objectCreator instanceof ObjectCreatorInterface) { throw new PapperConfigurationException('Argument objectCreator must be closure or instance of Papper\\ObjectCreatorInterface'); } $this->typeMap->setObjectCreator($objectCreator); }