Code Duplication    Length = 7-7 lines in 2 locations

src/Charcoal/Object/RoutableTrait.php 2 locations

@@ 578-584 (lines=7) @@
575
    protected function finalizeSlug($slug)
576
    {
577
        $prefix = $this->slugPrefix();
578
        if ($prefix) {
579
            $prefix = $this->generateRoutePattern((string)$prefix);
580
            if ($slug === $prefix) {
581
                throw new UnexpectedValueException('The slug is the same as the prefix.');
582
            }
583
            $slug = $prefix.preg_replace('!^'.preg_quote($prefix).'\b!', '', $slug);
584
        }
585
586
        $suffix = $this->slugSuffix();
587
        if ($suffix) {
@@ 587-593 (lines=7) @@
584
        }
585
586
        $suffix = $this->slugSuffix();
587
        if ($suffix) {
588
            $suffix = $this->generateRoutePattern((string)$suffix);
589
            if ($slug === $suffix) {
590
                throw new UnexpectedValueException('The slug is the same as the suffix.');
591
            }
592
            $slug = preg_replace('!\b'.preg_quote($suffix).'$!', '', $slug).$suffix;
593
        }
594
595
        return $slug;
596
    }