Code Duplication    Length = 7-8 lines in 3 locations

src/Services/SlugService.php 3 locations

@@ 155-162 (lines=8) @@
152
        $method = $config['method'];
153
        $maxLength = $config['maxLength'];
154
155
        if ($method === null) {
156
            $slugEngine = $this->getSlugEngine($attribute);
157
            $slug = $slugEngine->slugify($source, $separator);
158
        } elseif (is_callable($method)) {
159
            $slug = call_user_func($method, $source, $separator);
160
        } else {
161
            throw new \UnexpectedValueException('Sluggable "method" for ' . get_class($this->model) . ':' . $attribute . ' is not callable nor null.');
162
        }
163
164
        if (is_string($slug) && $maxLength) {
165
            $slug = mb_substr($slug, 0, $maxLength);
@@ 224-230 (lines=7) @@
221
            if (in_array($slug, $reserved)) {
222
223
                $method = $config['uniqueSuffix'];
224
                if ($method === null) {
225
                    $suffix = $this->generateSuffix($slug, $separator, collect($reserved));
226
                } elseif (is_callable($method)) {
227
                    $suffix = $method($slug, $separator, collect($reserved));
228
                } else {
229
                    throw new \UnexpectedValueException('Sluggable "uniqueSuffix" for ' . get_class($this->model) . ':' . $attribute . ' is not null, or a closure.');
230
                }
231
232
                return $slug . $separator . $suffix;
233
            }
@@ 288-294 (lines=7) @@
285
        }
286
287
        $method = $config['uniqueSuffix'];
288
        if ($method === null) {
289
            $suffix = $this->generateSuffix($slug, $separator, $list);
290
        } elseif (is_callable($method)) {
291
            $suffix = $method($slug, $separator, $list);
292
        } else {
293
            throw new \UnexpectedValueException('Sluggable "uniqueSuffix" for ' . get_class($this->model) . ':' . $attribute . ' is not null, or a closure.');
294
        }
295
296
        return $slug . $separator . $suffix;
297
    }