Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 1 addition & 44 deletions src/Illuminate/Validation/Rules/NotIn.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,55 +2,12 @@

namespace Illuminate\Validation\Rules;

use Illuminate\Contracts\Support\Arrayable;
use Stringable;

use function Illuminate\Support\enum_value;

class NotIn implements Stringable
class NotIn extends In
{
/**
* The name of the rule.
*
* @var string
*/
protected $rule = 'not_in';

/**
* The accepted values.
*
* @var array
*/
protected $values;

/**
* Create a new "not in" rule instance.
*
* @param \Illuminate\Contracts\Support\Arrayable|\BackedEnum|\UnitEnum|array|string $values
* @return void
*/
public function __construct($values)
{
if ($values instanceof Arrayable) {
$values = $values->toArray();
}

$this->values = is_array($values) ? $values : func_get_args();
}

/**
* Convert the rule to a validation string.
*
* @return string
*/
public function __toString()
{
$values = array_map(function ($value) {
$value = enum_value($value);

return '"'.str_replace('"', '""', $value).'"';
}, $this->values);

return $this->rule.':'.implode(',', $values);
}
}