<?php $segment = match ($segment) {
'\*' => '*',
'\{first}' => '{first}',
'{first}' => array_key_first(is_array($target) ? $target : collect($target)->all()),
'\{last}' => '{last}',
'{last}' => array_key_last(is_array($target) ? $target : collect($target)->all()),
default => $segment,