<?php
function alternate_switch($condition, $cases)
{
return $cases[$condition]();
}
$siteStatus = 'offline'; // Probably gotten from config or whatever!!
alternate_switch($siteStatus, [
'offline' => function () {
echo 'Site is offline';
},
'online' => function () {
echo 'Site is online';
}
]);