for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
namespace Simplario\Quedis;
use Simplario\Quedis\Interfaces\MessageInterface;
/**
* Class Message
* @package Simplario\Quedis
*/
class Message implements MessageInterface
{
* @var null|string
protected $token;
* @var mixed
protected $data;
* Message constructor.
* @param mixed $data
* @param null $token
public function __construct($data, $token = null)
$this->data = $data;
$this->token = $token !== null ? $token : $this->generateToken();
}
* @return string
protected function generateToken()
return implode('-', [uniqid(), mt_rand(1000000, 9999999), time()]);
public function encode()
return serialize([$this->getData(), $this->getToken()]);
* @param $encoded
* @return static
public static function decode($encoded)
$encoded = unserialize($encoded);
return new static($encoded[0], $encoded[1]);
public function getToken()
return $this->token;
* @param string $token
* @return $this
public function setToken($token)
$this->token = $token;
return $this;
* @return mixed
public function getData()
return $this->data;
* @param $data
public function setData($data)