Code Duplication    Length = 7-8 lines in 3 locations

src/Services/SlugService.php 3 locations

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