for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
namespace Itstructure\MFU\Processors;
use Exception;
use Illuminate\Support\MessageBag;
use Itstructure\MFU\Models\Mediafile;
/**
* Class BaseProcessor
* @package Itstructure\MFU\Processors
* @author Andrey Girnik <[email protected]>
*/
abstract class BaseProcessor
{
/************************* PROCESS ATTRIBUTES *************************/
* @var string
protected $currentDisk;
* @var Mediafile
protected $mediafileModel;
protected $processDirectory;
* @var MessageBag|null
protected $errors;
/************************* ABSTRACT METHODS ***************************/
abstract protected function setProcessParams(): void;
* @throws Exception
* @return bool
abstract protected function process(): bool;
abstract protected function afterProcess(): void;
/********************** PROCESS PUBLIC METHODS ***********************/
* @param array $config
* @return static
public static function getInstance(array $config = [])
$obj = new static();
foreach ($config as $key => $value) {
$obj->{'set' . ucfirst($key)}($value);
}
return $obj;
public function run(): bool
$this->setProcessParams();
$this->process();
$this->afterProcess();
return true;
* @param Mediafile $model
* @return $this
public function setMediafileModel(Mediafile $model)
$this->mediafileModel = $model;
return $this;
* @return Mediafile
public function getMediafileModel(): Mediafile
return $this->mediafileModel;
* @return int
public function getId()
return $this->mediafileModel->id;
* @return MessageBag|null
public function getErrors(): ?MessageBag
return $this->errors;