for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
namespace Puzzle\AMQP\Workers;
use Swarrot\Processor\ProcessorInterface;
use Puzzle\Pieces\EventDispatcher\NullEventDispatcher;
use Puzzle\Pieces\EventDispatcher\EventDispatcherAware;
class ProcessorInterfaceAdapter implements ProcessorInterface
{
use EventDispatcherAware;
private
$workerContext;
$workerContext
The PSR-2 coding standard requires that all properties in a class have their visibility explicitly declared. If you declare a property using
class A { var $property; }
the property is implicitly global.
To learn more about the PSR-2, please see the PHP-FIG site on the PSR-2.
public function __construct(WorkerContext $workerContext)
$this->workerContext = $workerContext;
$this->eventDispatcher = new NullEventDispatcher();
}
public function process(\Swarrot\Broker\Message $message, array $options)
$message = new MessageAdapter($message);
$this->workerContext->getLogger()->debug((string) $message);
$this->onWorkerProcess();
try
$processResult = $this->workerContext->getWorker()->process($message);
catch(\Exception $exception)
$this->onWorkerProcessed();
throw $exception;
return $processResult;
private function onWorkerProcess()
$this->eventDispatcher->dispatch('worker.process');
private function onWorkerProcessed()
$this->eventDispatcher->dispatch('worker.processed');
The PSR-2 coding standard requires that all properties in a class have their visibility explicitly declared. If you declare a property using
the property is implicitly global.
To learn more about the PSR-2, please see the PHP-FIG site on the PSR-2.