for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
namespace Wandu\Q\Adapter;
use Wandu\Q\Contracts\Adapter;
use Countable;
class ArrayAdapter implements Adapter, Countable
{
/** @var array */
protected $queue;
public function __construct()
$this->queue = [];
}
/**
* {@inheritdoc}
*/
public function flush()
public function count()
return count($this->queue);
public function send(string $payload)
$this->queue[] = [
'id' => uniqid(),
'payload' => $payload,
'reserved' => false,
];
public function receive()
foreach ($this->queue as $idx => $item) {
if (!$item['reserved']) {
$this->queue[$idx]['reserved'] = true;
return new ArrayJob($item['id'], $item['payload']);
public function remove($job)
/** @var \Wandu\Q\Adapter\ArrayJob $job */
if ($item['id'] === $job->getIdentifier()) {
array_splice($this->queue, $idx, 1);
return;