-<?php namespace BookStack\Entities\Tools;
+<?php
+
+namespace BookStack\Entities\Tools;
use BookStack\Entities\Models\BookChild;
use BookStack\Interfaces\Sluggable;
class SlugGenerator
{
-
/**
* Generate a fresh slug for the given entity.
* The slug will generated so it does not conflict within the same parent item.
while ($this->slugInUse($slug, $model)) {
$slug .= '-' . Str::random(3);
}
+
return $slug;
}
protected function formatNameAsSlug(string $name): string
{
$slug = Str::slug($name);
- if ($slug === "") {
+ if ($slug === '') {
$slug = substr(md5(rand(1, 500)), 0, 5);
}
+
return $slug;
}