Code Duplication    Length = 7-8 lines in 3 locations

src/Services/SlugService.php 3 locations

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