Maybe in PHP 8.6...

<?php
function slugger(string $input)
{
    return 
$input
        
|> \strtolower(...)
        |> 
\preg_replace('/[^a-z]/''-', ?)
        |> 
\trim(?, '-')
        |> 
\preg_replace('/-+/''-', ?);
}
var_dump(slugger('Hello, World!')); // string(11) "hello-world"
?>