1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253 |
- <?php
- namespace Predis\Configuration;
- use InvalidArgumentException;
- use Predis\Connection\ConnectionFactory;
- use Predis\Connection\ConnectionFactoryInterface;
- class ConnectionFactoryOption implements OptionInterface
- {
-
- public function filter(OptionsInterface $options, $value)
- {
- if ($value instanceof ConnectionFactoryInterface) {
- return $value;
- } else if (is_array($value)) {
- $factory = $this->getDefault($options);
- foreach ($value as $scheme => $initializer) {
- $factory->define($scheme, $initializer);
- }
- return $factory;
- } else {
- throw new InvalidArgumentException('Invalid value for the connections option');
- }
- }
-
- public function getDefault(OptionsInterface $options)
- {
- return new ConnectionFactory($options->profile);
- }
- }
|