simplify value objects by using anonymous classes
Ma27 opened this issue · comments
Maximilian Bosch commented
Description
most of the value objects are intended to be used at one special place for exactly one application service.
Therefore we should use anonymous classes to return the API, but keep the classes internal.
Approach
Methods in the business logic might look like this:
public function doSth()
{
// complex logic
return new class($result) {
private $result;
public function __construct(User $result)
{
$this->result = $result;
}
public function getResult()
{
return $this->result;
}
}
}
Maximilian Bosch commented
when restructuring the business logic in #310 it's better to have one common object that can be handled by middlewares properly