Files
2025-08-02 16:30:27 +02:00

80 lines
1.7 KiB
PHP

<?php
namespace KupShop\MessengerBundle\Message\Envelope;
abstract class AbstractEnvelope implements EnvelopeInterface
{
private $serializedMessage;
private $callback;
private $retryCount = 5;
private int $retryCountOriginal;
private $unixTimeStamp;
private string $id;
protected string $web;
public function __construct(string $serializedMessage, ?string $callback = null)
{
$this->serializedMessage = $serializedMessage;
$this->callback = $callback ? $callback : path('kupshop_messenger_callback_messagecallback', [], 0);
$this->web = getShopName();
$this->retryCountOriginal = $this->getRetryCount();
}
public function getSerializedMessage(): string
{
return $this->serializedMessage;
}
public function getUnixTimeStamp(): ?int
{
return $this->unixTimeStamp;
}
public function setUnixTimeStamp(int $unixTimeStamp): void
{
$this->unixTimeStamp = $unixTimeStamp;
}
public function getRetryCount(): int
{
return $this->retryCount;
}
public function getRetryIndex(): int
{
return ($this->retryCountOriginal ?? $this->retryCount) - $this->retryCount;
}
public function decreaseRetryCount(): void
{
$this->retryCount--;
}
public function getCallback(): string
{
return $this->callback;
}
public function getWeb(): string
{
return $this->web;
}
public function getId(): string
{
return $this->id ?? 'not yet';
}
public function setId(string $id): AbstractEnvelope
{
$this->id = $id;
return $this;
}
}