Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 12 additions & 26 deletions src/Message/PlainMessage.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,18 +9,15 @@
/**
* Simple message that gets you started.
* It has a name and an array of arguments.
* It does not enforce any types or properties so be careful on relying them
* It does not enforce any types or properties so be careful relying on them
* being there.
*/
final class PlainMessage implements Message, \ArrayAccess
{
private $name;
private $arguments;
private string $name;
private array $arguments;

/**
* @param string $name
*/
public function __construct($name, array $arguments = [])
public function __construct(string $name, array $arguments = [])
{
$this->name = $name;
$this->arguments = $arguments;
Expand All @@ -29,59 +26,48 @@ public function __construct($name, array $arguments = [])
/**
* {@inheritdoc}
*/
public function getName()
public function getName() : string
{
return $this->name;
}

/**
* @return array
*/
public function all()
public function all() : array
{
return $this->arguments;
}

/**
* Returns the argument if found or null.
*
* @param string $name
*
* @return mixed
*/
public function get($name)
public function get(string $name) : mixed
{
return $this->has($name) ? $this->arguments[$name] : null;
}

/**
* Checks whether the arguments contain the given key.
*
* @param string $name
*
* @return bool
*/
public function has($name)
public function has(string $name) : bool
{
return \array_key_exists($name, $this->arguments);
}

public function offsetGet($offset)
public function offsetGet(mixed $offset) : mixed
{
return $this->get($offset);
}

public function offsetExists($offset)
public function offsetExists(mixed $offset) : bool
{
return $this->has($offset);
}

public function offsetSet($offset, $value): void
public function offsetSet(mixed $offset, mixed $value): void
{
throw new \LogicException('Message is immutable');
}

public function offsetUnset($offset): void
public function offsetUnset(mixed $offset): void
{
throw new \LogicException('Message is immutable');
}
Expand Down
18 changes: 8 additions & 10 deletions src/Queue/PersistentQueue.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,23 +7,21 @@
use Bernard\Driver;
use Bernard\Envelope;
use Bernard\Serializer;
use SplObjectStorage;

class PersistentQueue extends AbstractQueue
{
protected $driver;
protected $serializer;
protected $receipts;

/**
* @param string $name
*/
public function __construct($name, Driver $driver, Serializer $serializer)
protected Driver $driver;
protected Serializer $serializer;
protected SplObjectStorage $receipts;

public function __construct(string $name, Driver $driver, Serializer $serializer)
{
parent::__construct($name);

$this->driver = $driver;
$this->serializer = $serializer;
$this->receipts = new \SplObjectStorage();
$this->receipts = new SplObjectStorage();

$this->register();
}
Expand All @@ -41,7 +39,7 @@ public function register(): void
/**
* {@inheritdoc}
*/
public function count()
public function count() : int
{
$this->errorIfClosed();

Expand Down