ClientProfile.php 1009 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  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\Profiles\ServerProfile;
  12. use Predis\Profiles\IServerProfile;
  13. /**
  14. * Option class that handles server profiles to be used by a client.
  15. *
  16. * @author Daniele Alessandri <suppakilla@gmail.com>
  17. */
  18. class ClientProfile extends Option
  19. {
  20. /**
  21. * {@inheritdoc}
  22. */
  23. public function validate($value)
  24. {
  25. if ($value instanceof IServerProfile) {
  26. return $value;
  27. }
  28. if (is_string($value)) {
  29. return ServerProfile::get($value);
  30. }
  31. throw new \InvalidArgumentException(
  32. "Invalid value for the profile option"
  33. );
  34. }
  35. /**
  36. * {@inheritdoc}
  37. */
  38. public function getDefault()
  39. {
  40. return ServerProfile::getDefault();
  41. }
  42. }