Code Duplication    Length = 7-8 lines in 3 locations

src/Services/SlugService.php 3 locations

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