1
0
mirror of https://github.com/flarum/core.git synced 2025-10-12 07:24:27 +02:00
Files
php-flarum/src/Queue/QueueFactory.php
Franz Liedke d492579638 Apply fixes from StyleCI
[ci skip] [skip ci]
2019-11-28 00:16:50 +00:00

56 lines
1.1 KiB
PHP

<?php
/*
* This file is part of Flarum.
*
* For detailed copyright and license information, please view the
* LICENSE file that was distributed with this source code.
*/
namespace Flarum\Queue;
use Illuminate\Contracts\Queue\Factory;
class QueueFactory implements Factory
{
/**
* @var callable
*/
private $factory;
/**
* The cached queue instance.
*
* @var \Illuminate\Contracts\Queue\Queue
*/
private $queue;
/**
* QueueFactory constructor.
*
* Expects a callback that will be called to instantiate the queue adapter,
* once requested by the application.
*
* @param callable $factory
*/
public function __construct(callable $factory)
{
$this->factory = $factory;
}
/**
* Resolve a queue connection instance.
*
* @param string $name
* @return \Illuminate\Contracts\Queue\Queue
*/
public function connection($name = null)
{
if (is_null($this->queue)) {
$this->queue = ($this->factory)();
}
return $this->queue;
}
}