@@ 161-168 (lines=8) @@ | ||
158 | $maxLength = $config['maxLength']; |
|
159 | $maxLengthKeepWords = $config['maxLengthKeepWords']; |
|
160 | ||
161 | if ($method === null) { |
|
162 | $slugEngine = $this->getSlugEngine($attribute); |
|
163 | $slug = $slugEngine->slugify($source, $separator); |
|
164 | } elseif (is_callable($method)) { |
|
165 | $slug = call_user_func($method, $source, $separator); |
|
166 | } else { |
|
167 | throw new \UnexpectedValueException('Sluggable "method" for ' . get_class($this->model) . ':' . $attribute . ' is not callable nor null.'); |
|
168 | } |
|
169 | ||
170 | $len = mb_strlen($slug); |
|
171 | if (is_string($slug) && $maxLength && $len > $maxLength) { |
|
@@ 237-243 (lines=7) @@ | ||
234 | if (is_array($reserved)) { |
|
235 | if (in_array($slug, $reserved)) { |
|
236 | $method = $config['uniqueSuffix']; |
|
237 | if ($method === null) { |
|
238 | $suffix = $this->generateSuffix($slug, $separator, collect($reserved)); |
|
239 | } elseif (is_callable($method)) { |
|
240 | $suffix = $method($slug, $separator, collect($reserved)); |
|
241 | } else { |
|
242 | throw new \UnexpectedValueException('Sluggable "uniqueSuffix" for ' . get_class($this->model) . ':' . $attribute . ' is not null, or a closure.'); |
|
243 | } |
|
244 | ||
245 | return $slug . $separator . $suffix; |
|
246 | } |
|
@@ 305-311 (lines=7) @@ | ||
302 | } |
|
303 | ||
304 | $method = $config['uniqueSuffix']; |
|
305 | if ($method === null) { |
|
306 | $suffix = $this->generateSuffix($slug, $separator, $list); |
|
307 | } elseif (is_callable($method)) { |
|
308 | $suffix = $method($slug, $separator, $list); |
|
309 | } else { |
|
310 | throw new \UnexpectedValueException('Sluggable "uniqueSuffix" for ' . get_class($this->model) . ':' . $attribute . ' is not null, or a closure.'); |
|
311 | } |
|
312 | ||
313 | return $slug . $separator . $suffix; |
|
314 | } |