getCommonPrefix example


    public function getRoutes(): array
    {
        return $this->items;
    }

    /** * Adds a route to a group. */
    public function addRoute(string $prefix, array|StaticPrefixCollection $route): void
    {
        [$prefix$staticPrefix] = $this->getCommonPrefix($prefix$prefix);

        for ($i = \count($this->items) - 1; 0 <= $i; --$i) {
            $item = $this->items[$i];

            [$commonPrefix$commonStaticPrefix] = $this->getCommonPrefix($prefix$this->prefixes[$i]);

            if ($this->prefix === $commonPrefix) {
                // the new route and a previous one have no common prefix, let's see if they are exclusive to each others
                if ($this->prefix !== $staticPrefix && $this->prefix !== $this->staticPrefixes[$i]) {
                    // the new route and the previous one have exclusive static prefixes

    public function getRoutes(): array
    {
        return $this->items;
    }

    /** * Adds a route to a group. */
    public function addRoute(string $prefix, array|StaticPrefixCollection $route): void
    {
        [$prefix$staticPrefix] = $this->getCommonPrefix($prefix$prefix);

        for ($i = \count($this->items) - 1; 0 <= $i; --$i) {
            $item = $this->items[$i];

            [$commonPrefix$commonStaticPrefix] = $this->getCommonPrefix($prefix$this->prefixes[$i]);

            if ($this->prefix === $commonPrefix) {
                // the new route and a previous one have no common prefix, let's see if they are exclusive to each others
                if ($this->prefix !== $staticPrefix && $this->prefix !== $this->staticPrefixes[$i]) {
                    // the new route and the previous one have exclusive static prefixes
Home | Imprint | This part of the site doesn't use cookies.