Cviebrock\EloquentSluggable\Services\SlugService::validateSlug PHP Method

validateSlug() protected method

Checks that the given slug is not a reserved word.
protected validateSlug ( string $slug, array $config, string $attribute ) : string
$slug string
$config array
$attribute string
return string
    protected function validateSlug($slug, array $config, $attribute)
    {
        $separator = $config['separator'];
        $reserved = $config['reserved'];
        if ($reserved === null) {
            return $slug;
        }
        // check for reserved names
        if ($reserved instanceof \Closure) {
            $reserved = $reserved($this->model);
        }
        if (is_array($reserved)) {
            if (in_array($slug, $reserved)) {
                return $slug . $separator . '1';
            }
            return $slug;
        }
        throw new \UnexpectedValueException('Sluggable "reserved" for ' . get_class($this->model) . ':' . $attribute . ' is not null, an array, or a closure that returns null/array.');
    }