<?php
 namespace App\EntityClone; abstract class BaseAbstract { protected $id; protected \App\Entity\GeneralAbstract $entityNew; public function __construct($id, \App\Entity\GeneralAbstract $entityNew) { $this->id = $id; $this->entityNew = $entityNew; } public function populate() { if ($this->entityNew->getOperation()!='insert') { throw new \Exception("You can clone an entity only for `insert` operation"); } return $this->attachFields(); } abstract protected function attachFields(); } 