Вход Регистрация
Файл: vendor/laravel/framework/src/Illuminate/Validation/Rules/NotIn.php
Строк: 49
<?php

namespace IlluminateValidationRules;

use 
BackedEnum;
use 
IlluminateContractsSupportArrayable;
use 
UnitEnum;

class 
NotIn
{
    
/**
     * 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  IlluminateContractsSupportArrayable|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 match (true) {
                
$value instanceof BackedEnum => $value->value,
                
$value instanceof UnitEnum => $value->name,
                default => 
$value,
            };

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

        return 
$this->rule.':'.implode(','$values);
    }
}
Онлайн: 1
Реклама