<?php
$env_to_bool = function ($v): bool {
    if (is_bool($v)) return $v;
    if (is_numeric($v)) return (bool) intval($v);
    if (is_string($v)) {
        $n = mb_strtolower(trim($v));
        if (in_array($n, ['1','true','on','yes','y','t'], true))  return true;
        if (in_array($n, ['0','false','off','no','n','f'], true)) return false;
    }
    throw new Exception('Could not convert value to bool');
};

return $env_to_bool;