<?php
 namespace App\ImportEmailBookings; abstract class PopulateImportedOrderAbstract { protected \App\ImportEmailBookings\ParserAbstract $parser; protected string $externalSystemCode; protected ?string $skipReason = null; 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->skipReason) { $this->populateImportedOrderFields($importedOrder); } } abstract protected function checkParsedData() :void ; abstract protected function populateImportedOrderFields(\App\ImportedOrder\Order $importedOrder) :void ; public function getSkipReason(): ?string { return $this->skipReason; } } 