public function __construct($queue, $id, $class, array $data = null)
{
$this->redis = Redis::instance();
if (!is_string($queue) or empty($queue)) {
throw new \InvalidArgumentException('The Job queue "(' . gettype($queue) . ')' . $queue . '" must a non-empty string');
}
$this->queue = $queue;
$this->id = $id;
$this->data = $data;
if ($class instanceof Closure) {
$this->class = 'Resque\\Helpers\\ClosureJob';
$this->data = $class;
} else {
$this->class = $class;
if (strpos($this->class, '@')) {
list($this->class, $this->method) = explode('@', $this->class, 2);
}
// Remove any spaces or back slashes
$this->class = trim($this->class, '\\ ');
}
$this->payload = $this->createPayload();
Event::fire(Event::JOB_INSTANCE, $this);
}