Code Duplication    Length = 7-8 lines in 3 locations

src/Services/SlugService.php 3 locations

@@ 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
    }
@@ 164-171 (lines=8) @@
161
        $maxLength = $config['maxLength'];
162
        $maxLengthKeepWords = $config['maxLengthKeepWords'];
163
164
        if ($method === null) {
165
            $slugEngine = $this->getSlugEngine($attribute);
166
            $slug = $slugEngine->slugify($source, $separator);
167
        } elseif (is_callable($method)) {
168
            $slug = call_user_func($method, $source, $separator);
169
        } else {
170
            throw new \UnexpectedValueException('Sluggable "method" for ' . get_class($this->model) . ':' . $attribute . ' is not callable nor null.');
171
        }
172
173
        $len = mb_strlen($slug);
174
        if (is_string($slug) && $maxLength && $len > $maxLength) {
@@ 240-246 (lines=7) @@
237
        if (is_array($reserved)) {
238
            if (in_array($slug, $reserved)) {
239
                $method = $config['uniqueSuffix'];
240
                if ($method === null) {
241
                    $suffix = $this->generateSuffix($slug, $separator, collect($reserved));
242
                } elseif (is_callable($method)) {
243
                    $suffix = $method($slug, $separator, collect($reserved));
244
                } else {
245
                    throw new \UnexpectedValueException('Sluggable "uniqueSuffix" for ' . get_class($this->model) . ':' . $attribute . ' is not null, or a closure.');
246
                }
247
248
                return $slug . $separator . $suffix;
249
            }