using Php;

namespace PhpNative {
    public int sleep_static (int seconds, string php_file, int php_line) throws Error {
        if (seconds <= 0) {
            return 0;
        }
        Thread.usleep ((ulong) seconds * 1000000UL);
        return 0;
    }

    public bool usleep_static (int microseconds, string php_file, int php_line) throws Error {
        if (microseconds > 0) {
            Thread.usleep ((ulong) microseconds);
        }
        return true;
    }

    public zval sleep_zval (zval seconds, string php_file, int php_line) throws Error {
        return zval.integer (sleep_static (zval_to_int (seconds), php_file, php_line));
    }

    public zval usleep_zval (zval microseconds, string php_file, int php_line) throws Error {
        return zval.boolean (usleep_static (zval_to_int (microseconds), php_file, php_line));
    }
}
