Code Duplication    Length = 7-7 lines in 2 locations

src/Charcoal/Object/RoutableTrait.php 2 locations

@@ 606-612 (lines=7) @@
603
    protected function finalizeSlug($slug)
604
    {
605
        $prefix = $this->slugPrefix();
606
        if ($prefix) {
607
            $prefix = $this->generateRoutePattern((string)$prefix);
608
            if ($slug === $prefix) {
609
                throw new UnexpectedValueException('The slug is the same as the prefix.');
610
            }
611
            $slug = $prefix.preg_replace('!^'.preg_quote($prefix).'\b!', '', $slug);
612
        }
613
614
        $suffix = $this->slugSuffix();
615
        if ($suffix) {
@@ 615-621 (lines=7) @@
612
        }
613
614
        $suffix = $this->slugSuffix();
615
        if ($suffix) {
616
            $suffix = $this->generateRoutePattern((string)$suffix);
617
            if ($slug === $suffix) {
618
                throw new UnexpectedValueException('The slug is the same as the suffix.');
619
            }
620
            $slug = preg_replace('!\b'.preg_quote($suffix).'$!', '', $slug).$suffix;
621
        }
622
623
        $slug = rtrim($slug, '/');
624