for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
namespace Puzzle\AMQP\Consumers;
use Puzzle\AMQP\Consumer;
use Swarrot\Broker\MessageProvider\PeclPackageMessageProvider;
use Swarrot\Consumer as SwarrotConsumer;
use Swarrot\Processor\Stack;
use Swarrot\Processor\ProcessorInterface;
use Psr\Log\NullLogger;
use Psr\Log\LoggerAwareTrait;
use Puzzle\AMQP\Client;
use Puzzle\AMQP\Workers\WorkerContext;
abstract class AbstractConsumer implements Consumer
{
use LoggerAwareTrait;
protected
$messageProvider;
$messageProvider
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.
private
$client,
$client
$processor,
$workerContext;
public function __construct()
$this->logger = new NullLogger();
}
public function consume(ProcessorInterface $processor, Client $client, WorkerContext $workerContext)
$this->processor = $processor;
$this->client = $client;
$this->workerContext = $workerContext;
$this->setMessageProvider();
private function setMessageProvider()
$this->messageProvider = new PeclPackageMessageProvider($this->client->getQueue($this->workerContext->queue));
protected function getBaseStack()
$stack = (new Stack\Builder())
->push('Swarrot\Processor\SignalHandler\SignalHandlerProcessor', $this->logger)
->push('Swarrot\Processor\ExceptionCatcher\ExceptionCatcherProcessor', $this->logger)
;
return $stack;
protected function getSwarrotConsumer(Stack\Builder $stack)
return new SwarrotConsumer(
$this->messageProvider,
$stack->resolve($this->processor),
null,
$this->logger
);
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.