%PDF- %GIF98; %PNG;
Server : ApacheSystem : Linux host.digitalbabaji.in 4.18.0-513.11.1.el8_9.x86_64 #1 SMP Wed Jan 17 02:00:40 EST 2024 x86_64 User : addictionfreeind ( 1003) PHP Version : 7.2.34 Disable Function : exec,passthru,shell_exec,system Directory : /home/addictionfreeind/www/admin1/vendor/graham-campbell/gitlab/src/Cache/ |
Upload File : |
<?php
declare(strict_types=1);
/*
* This file is part of Laravel GitLab.
*
* (c) Graham Campbell <hello@gjcampbell.co.uk>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace GrahamCampbell\GitLab\Cache;
use GrahamCampbell\BoundedCache\BoundedCacheInterface;
use GrahamCampbell\Manager\ConnectorInterface;
use Illuminate\Contracts\Cache\Factory;
use InvalidArgumentException;
/**
* This is the cache connection factory class.
*
* @author Graham Campbell <hello@gjcampbell.co.uk>
*/
class ConnectionFactory
{
/**
* The cache factory instance.
*
* @var \Illuminate\Contracts\Cache\Factory|null
*/
private ?Factory $cache;
/**
* Create a new connection factory instance.
*
* @param \Illuminate\Contracts\Cache\Factory|null $cache
*
* @return void
*/
public function __construct(Factory $cache = null)
{
$this->cache = $cache;
}
/**
* Establish a cache connection.
*
* @param array $config
*
* @throws \InvalidArgumentException
*
* @return \GrahamCampbell\BoundedCache\BoundedCacheInterface
*/
public function make(array $config): BoundedCacheInterface
{
return $this->createConnector($config)->connect($config);
}
/**
* Create a connector instance based on the configuration.
*
* @param array $config
*
* @throws \InvalidArgumentException
*
* @return \GrahamCampbell\Manager\ConnectorInterface
*/
public function createConnector(array $config): ConnectorInterface
{
if (!isset($config['driver'])) {
throw new InvalidArgumentException('A driver must be specified.');
}
switch ($config['driver']) {
case 'illuminate':
return new Connector\IlluminateConnector($this->cache);
}
throw new InvalidArgumentException("Unsupported driver [{$config['driver']}].");
}
}