In.php 838B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. <?php
  2. namespace Illuminate\Validation\Rules;
  3. class In
  4. {
  5. /**
  6. * The name of the rule.
  7. */
  8. protected $rule = 'in';
  9. /**
  10. * The accepted values.
  11. *
  12. * @var array
  13. */
  14. protected $values;
  15. /**
  16. * Create a new in rule instance.
  17. *
  18. * @param array $values
  19. * @return void
  20. */
  21. public function __construct(array $values)
  22. {
  23. $this->values = $values;
  24. }
  25. /**
  26. * Convert the rule to a validation string.
  27. *
  28. * @return string
  29. *
  30. * @see \Illuminate\Validation\ValidationRuleParser::parseParameters
  31. */
  32. public function __toString()
  33. {
  34. $values = array_map(function ($value) {
  35. return '"'.str_replace('"', '""', $value).'"';
  36. }, $this->values);
  37. return $this->rule.':'.implode(',', $values);
  38. }
  39. }