public function getInstance()
{
if (!is_null($this->instance)) {
return $this->instance;
}
if (!class_exists($this->class)) {
throw new \RuntimeException('Could not find job class "' . $this->class . '"');
}
if (!method_exists($this->class, $this->method) or !is_callable(array($this->class, $this->method))) {
throw new \RuntimeException('Job class "' . $this->class . '" does not contain a public "' . $this->method . '" method');
}
$class = new \ReflectionClass($this->class);
if ($class->isAbstract()) {
throw new \RuntimeException('Job class "' . $this->class . '" cannot be an abstract class');
}
$instance = $class->newInstance();
return $this->instance = $instance;
}