-
Hi, I've some object that have some properties defined in the constructor while others can be accessed through setter. Is this something Valinor support ? Thanks again for the lib :) |
Beta Was this translation helpful? Give feedback.
Answered by
romm
Mar 9, 2022
Replies: 1 comment 2 replies
-
Hi @magnetik, this library recommends objects immutability so it wont allow automatic setters calls; however if for some reason you need this kind of operation, you can use the object binding like below (there is no documentation yet because I'm not sure the current implementation will make it to v1.0): (new \CuyZ\Valinor\MapperBuilder())
->bind(function (string $string, int $int, float $float): SomeClassWithSetter {
$class = new SomeClassWithSetter($string, $int);
$class->setFloat($float);
return $class;
})
->mapper()
->map(SomeClassWithSetter::class, [/* … */]); |
Beta Was this translation helpful? Give feedback.
2 replies
Answer selected by
magnetik
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hi @magnetik, this library recommends objects immutability so it wont allow automatic setters calls; however if for some reason you need this kind of operation, you can use the object binding like below (there is no documentation yet because I'm not sure the current implementation will make it to v1.0):