Code Duplication    Length = 19-19 lines in 2 locations

src/ServiceProvider.php 1 location

@@ 358-376 (lines=19) @@
355
     *
356
     * @return string
357
     */
358
    protected function generateSuffix(string $slug, string $separator, Collection $list): string
359
    {
360
        $len = strlen($slug . $separator);
361
362
        // If the slug already exists, but belongs to
363
        // our model, return the current suffix.
364
        if ($list->search($slug) === $this->model->getKey()) {
365
            $suffix = explode($separator, $slug);
366
367
            return end($suffix);
368
        }
369
370
        $list->transform(function ($value, $key) use ($len) {
371
            return (int) substr($value, $len);
372
        });
373
374
        // find the highest value and return one greater.
375
        return $list->max() + 1;
376
    }
377
378
    /**
379
     * Get all existing slugs that are similar to the given slug.

src/Services/SlugService.php 1 location

@@ 344-362 (lines=19) @@
341
     *
342
     * @return string
343
     */
344
    protected function generateSuffix(string $slug, string $separator, Collection $list): string
345
    {
346
        $len = strlen($slug . $separator);
347
348
        // If the slug already exists, but belongs to
349
        // our model, return the current suffix.
350
        if ($list->search($slug) === $this->model->getKey()) {
351
            $suffix = explode($separator, $slug);
352
353
            return end($suffix);
354
        }
355
356
        $list->transform(function ($value, $key) use ($len) {
357
            return (int) substr($value, $len);
358
        });
359
360
        // find the highest value and return one greater.
361
        return $list->max() + 1;
362
    }
363
364
    /**
365
     * Get all existing slugs that are similar to the given slug.