<?php
 namespace App\ImportEmailBookings; abstract class PopulateImportedOrderAbstract { protected \App\ImportEmailBookings\ParserAbstract $parser; protected string $externalSystemCode; protected bool $skipEmail = false; public function __construct(\App\ImportEmailBookings\ParserAbstract $parser) { $this->parser = $parser; } public function execute(\App\ImportedOrder\Order $importedOrder) :void { if (!isset($this->externalSystemCode) or !strlen($this->externalSystemCode)) { throw new \Exception('The external system code is not defined for class ' . get_called_class() ); } $this->checkParsedData(); if (!$this->skipEmail) { $this->populateImportedOrderFields($importedOrder); } } abstract protected function checkParsedData() :void ; abstract protected function populateImportedOrderFields(\App\ImportedOrder\Order $importedOrder) :void ; public function shouldBeSkipped() :bool { return $this->skipEmail; } } 