ClientConnectionFactory.php 695 B

123456789101112131415161718192021222324252627282930313233
  1. <?php
  2. /*
  3. * This file is part of the Predis package.
  4. *
  5. * (c) Daniele Alessandri <suppakilla@gmail.com>
  6. *
  7. * For the full copyright and license information, please view the LICENSE
  8. * file that was distributed with this source code.
  9. */
  10. namespace Predis\Options;
  11. use Predis\IConnectionFactory;
  12. use Predis\ConnectionFactory;
  13. class ClientConnectionFactory extends Option
  14. {
  15. public function validate($value)
  16. {
  17. if ($value instanceof IConnectionFactory) {
  18. return $value;
  19. }
  20. if (is_array($value)) {
  21. return new ConnectionFactory($value);
  22. }
  23. }
  24. public function getDefault()
  25. {
  26. return new ConnectionFactory();
  27. }
  28. }