You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

13 lines
437 B
PHP

<?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;