/** * Constructor * * @author Art <*****@*****.**> * * @param Redis $redis The Redis instance with an active connection. If omitted, a new one will be * created and an attempt to connect to localhost with default settings will * be made. * @param Config $cfg Your custom configuration * @param LoggerInterface $logger A logger object. If omitted, AloFramework\Log will be used. * * @throws SEx When $redis isn't supplied and we're unable to connect to localhost. */ public function __construct(Redis $redis = null, Config $cfg = null, LoggerInterface $logger = null) { //@codeCoverageIgnoreStart if (!$redis) { $redis = new Redis(); if (!$redis->connect('127.0.0.1')) { throw new SEx('Unable to connect to Redis @ 127.0.0.1'); } } //@codeCoverageIgnoreEnd $this->client = $redis; //Parent constructor must be called after $this->client is set parent::__construct($cfg, $logger); }
/** * Constructor * * @author Art <*****@*****.**> * * @param PDO $pdo PDO instance to use * @param Config $cfg Your custom configuration * @param LoggerInterface $logger A logger object. If omitted, AloFramework\Log will be used. */ public function __construct(PDO $pdo, Config $cfg = null, LoggerInterface $logger = null) { $this->client = $pdo; //Parent constructor must be called after $this->client is set parent::__construct($cfg, $logger); }