for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
namespace NeedleProject\Transaction;
/**
* Class Executor
*
* @package NeedleProject\Transaction
* @author Adrian Tilita <[email protected]>
*/
class Executor
{
* @var \ArrayIterator|null
private $processList = null;
* Executor constructor.
public function __construct()
$this->processList = new \ArrayIterator();
}
* @param ProcessInterface $process
public function addProcess(ProcessInterface $process)
$this->processList->append($process);
* Execute a set of processes
public function execute()
$this->processList->rewind();
while ($this->processList->valid()) {
$this->processList->current()->execute();
$this->processList->next();
* Rollback in reverse order
public function rollBack()
$maxOffset = $this->processList->count() - 1;
for ($i = $maxOffset; $i >= 0; $i--) {
/** @var ProcessInterface $currentProcess */
$currentProcess = $this->processList->offsetGet($i);
// Exclude rolling back processes that has not been executed
if ($currentProcess->hasExecuted() === false) {
hasExecuted()
NeedleProject\Transaction\ProcessInterface
execute()
This check marks calls to methods that do not seem to exist on an object.
This is most likely the result of a method being renamed without all references to it being renamed likewise.
continue;
$currentProcess->rollBack();
This check marks calls to methods that do not seem to exist on an object.
This is most likely the result of a method being renamed without all references to it being renamed likewise.