NotIn.php 771B

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. <?php
  2. namespace Illuminate\Validation\Rules;
  3. class NotIn
  4. {
  5. /**
  6. * The name of the rule.
  7. */
  8. protected $rule = 'not_in';
  9. /**
  10. * The accepted values.
  11. *
  12. * @var array
  13. */
  14. protected $values;
  15. /**
  16. * Create a new "not 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. public function __toString()
  31. {
  32. $values = array_map(function ($value) {
  33. return '"'.str_replace('"', '""', $value).'"';
  34. }, $this->values);
  35. return $this->rule.':'.implode(',', $values);
  36. }
  37. }