for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
/*
* This file is part of Laravel SMSFactor.
*
* (c) Filippo Galante <[email protected]>
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace IlGala\SMSFactor\Connectors;
use InvalidArgumentException;
/**
* This is the adapter connection factory class.
* @author Filippo Galante <[email protected]>
class ConnectionFactory
{
* Establish an adapter connection.
* @param array $config
* @return \IlGala\SMSFactor\Adapters\AdapterInterface
public function make(array $config)
return $this->createConnector($config)->connect($config);
}
* Create a connector instance based on the configuration.
* @throws \InvalidArgumentException
* @return \GrahamCampbell\Manager\ConnectorInterface
public function createConnector(array $config)
if (!isset($config['driver'])) {
throw new InvalidArgumentException('A driver must be specified.');
switch ($config['driver']) {
case 'buzz':
return new BuzzConnector();
case 'guzzle':
return new GuzzleConnector();
case 'guzzlehttp':
return new GuzzleHttpConnector();
throw new InvalidArgumentException("Unsupported driver [{$config['driver']}].");