for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
namespace Ccovey\RabbitMQ;
use PhpAmqpLib\Channel\AMQPChannel;
use PhpAmqpLib\Message\AMQPMessage;
use Symfony\Component\Stopwatch\StopwatchEvent;
use Throwable;
class QueuedMessage implements QueuedMessageInterface
{
/**
* @var AMQPMessage
*/
private $message;
* @var array
private $body;
* @var AMQPChannel
private $queueName;
* @var bool
private $failed = false;
* @var Throwable|null
private $throwable;
public function __construct(AMQPMessage $message)
$this->message = $message;
$this->body = json_decode($this->message->body, 1);
$this->queueName = $this->message->delivery_info['routing_key'];
}
public function getQueueName() : string
return $this->queueName;
public function getDeliveryTag() : string
return $this->message->delivery_info['delivery_tag'];
public function fail(Throwable $throwable = null)
$this->throwable = $throwable;
$this->failed = true;
public function isFailed() : bool
return $this->failed;
public function getThrowable()
return $this->throwable;
public function getBody() : array
return $this->body;
public function getRawBody() : string
return $this->message->body;
public function setStopWatchEvent(StopwatchEvent $stopwatchEvent)
$this->stopwatchEvent = $stopwatchEvent;
stopwatchEvent
In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:
class MyClass { } $x = new MyClass(); $x->foo = true;
Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion:
class MyClass { public $foo; } $x = new MyClass(); $x->foo = true;
* @param string $value
*
* @return mixed|null
public function __get(string $value)
return $this->body[$value] ?? null;
In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:
Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion: