Sententiaregum / Sententiaregum

A social network based on Symfony3 and ReactJS.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

simplify value objects by using anonymous classes

Ma27 opened this issue · comments

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;
        }
    }
}

when restructuring the business logic in #310 it's better to have one common object that can be handled by middlewares properly