Recently I had an interview project, which I did and sent, so this question is not for avoiding thinking. I am just struggling to build my own opinion about it so I decided to ask in public.My question in general is that: is the code design is too complex?I know the opinions may vary, but in general: do you PHP prefer the flat code and keeping the structures in just arrays, or is it better for you to spend twice a time but have something participated into small classes?The code is in this GitHub repo.The main class of this project is an API class. I call it the gateway point, or a package entry point. I was looking for existence of any pattern like that and could not find it, I mean the pattern of having a single class as a gateway point or rather an API for the whole package.<?phpnamespace Boarding;use Boarding\Card\Factory\CardFactoryInterface;use Boarding\Card\Stack;use Boarding\Route\Descripting\RouteDescription;use Boarding\Route\Descripting\RouteDescriptorInterface;use Boarding\Route\PathFinding\PathFindingStrategyInterface;use Boarding\Vehicle\Factory\VehicleFactoryInterface;/** * Class Api * @package Boarding */class Api{    /**     * @var CardFactoryInterface     */    private $cardFactory;    /**     * @var PathFindingStrategyInterface     */    private $pathFindingStrategy;    /**     * @var RouteDescriptorInterface     */    private $descriptor;    /**     * @param CardFactoryInterface $cardFactory     * @param PathFindingStrategyInterface $pathFindingStrategy     * @param RouteDescriptorInterface $routeDescriptor     */    public function __construct(        CardFactoryInterface $cardFactory,        PathFindingStrategyInterface $pathFindingStrategy,        RouteDescriptorInterface $routeDescriptor    ) {        $this->cardFactory = $cardFactory;        $this->pathFindingStrategy = $pathFindingStrategy;        $this->descriptor = $routeDescriptor;    }    /**     * Create a new Stack object instance, using injected factory object     *     * @param $data     * @return Stack     */    public function createStack($data)    {        $stack = new Stack();        foreach ($data as $element) {            $stack->addCard($this->cardFactory->createCard($element));        }        return $stack;    }    /**     * @param Stack $stack     * @return Route     */    public function findRoute(Stack $stack)    {        return $this->pathFindingStrategy->findPath($stack);    }    /**     * @param Route $route     * @return RouteDescription     */    public function describeRoute(Route $route)    {        return $this->descriptor->describeRoute($route);    }}Example of the too complex point I am sensing is maybe the mapping from Card to Leg. The Card is an class representing user input data, and Leg the output, generated from the API. I am not sure if I should use separate class or maybe the same one as they are very similar in the structure, or maybe even they are identical. I do always separate classes like that to keep modifications easy but then the pragmatic approach tells me that this is too much and I am losing too much time thinking about where to put these basic things.The Card class:/** * Class Card * @package Boarding */class Card{    /**     * @var string     */    private $from;    /**     * @var string     */    private $to;    /**     * @var string     */    private $seat;    /**     * @var AbstractVehicle     */    private $vehicle;    /**     * @var string[]     */    private $additionalInfo = [];    /**     * Card constructor.     * @param string $from     * @param string $to     * @param string $seat     * @param AbstractVehicle $vehicle     */    public function __construct($from = null, $to = null, $seat = null, AbstractVehicle $vehicle = null)    {        $this->from = $from;        $this->to = $to;        $this->seat = $seat;        $this->vehicle = $vehicle;    }    /**     * @return string     */    public function getFrom()    {        return $this->from;    }    /**     * @param string $from     */    public function setFrom($from)    {        $this->from = $from;    }    /**     * @return string     */    public function getTo()    {        return $this->to;    }    /**     * @param string $to     */    public function setTo($to)    {        $this->to = $to;    }    /**     * @return string     */    public function getSeat()    {        return $this->seat;    }    /**     * @param string $seat     */    public function setSeat($seat)    {        $this->seat = $seat;    }    /**     * @return AbstractVehicle     */    public function getVehicle()    {        return $this->vehicle;    }    /**     * @param AbstractVehicle $vehicle     */    public function setVehicle($vehicle)    {        $this->vehicle = $vehicle;    }    /**     * @param $name     * @return bool     */    public function getAdditionalInfo($name)    {        return isset($this->additionalInfo[$name]) ? $this->additionalInfo[$name] : null;    }    /**     * @param $name     * @param $value     */    public function setAdditionalInfo($name, $value)    {        $this->additionalInfo[$name] = $value;    }    /**     * @return \string[]     */    public function getAllAdditionalInfo()    {        return $this->additionalInfo;    }}
Boarding cards route finder
php;object oriented