Beispiel #1
0
function loco_flag_integer($f)
{
    if (is_numeric($f)) {
        $f = (int) $f;
    } else {
        $f = 'LOCO_FLAG_' . strtoupper($f);
        $f = defined($f) ? constant($f) : -1;
    }
    $flags = loco_flags();
    if (!isset($flags[$f])) {
        throw new InvalidArgumentException('Unknown flag, ' . var_export(func_get_arg(0), 1));
    }
    return $f;
}
function loco_flag_integer($f)
{
    if (is_numeric($f)) {
        $f = (int) $f;
    } else {
        $f = 'LOCO_FLAG_' . strtoupper($f);
        if (defined($f)) {
            $f = constant($f);
        } else {
            $f = array_search($f, loco_flags(), true);
            if (false === $f) {
                $f = -2;
            }
        }
    }
    if ($f > 5 || $f < -1) {
        throw new InvalidArgumentException('Unknown flag, ' . json_encode(func_get_arg(0)));
    }
    return $f;
}