ClientConnectionFactory.php 907 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  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. /**
  14. * Option class that returns a connection factory to be used by a client.
  15. *
  16. * @author Daniele Alessandri <suppakilla@gmail.com>
  17. */
  18. class ClientConnectionFactory extends Option
  19. {
  20. /**
  21. * {@inheritdoc}
  22. */
  23. public function validate($value)
  24. {
  25. if ($value instanceof IConnectionFactory) {
  26. return $value;
  27. }
  28. if (is_array($value)) {
  29. return new ConnectionFactory($value);
  30. }
  31. }
  32. /**
  33. * {@inheritdoc}
  34. */
  35. public function getDefault()
  36. {
  37. return new ConnectionFactory();
  38. }
  39. }