public static function writeFile($file, $content)
    {
        $handle = fopen($file, 'w');
        if (!self::lockFile($handle, LOCK_EX | LOCK_NB)) {
            $exception = array(
                "message" => 'exception_file_cannot_be_locked_for_writing',
                "parameters" => array(
                    "%file%" => basename($file),
                )
            );
            throw new RuntimeException(json_encode($exception));
        }
        if (fwrite($handle, $content) === false) {
            $exception = array(
                "message" => 'exception_file_cannot_be_written',
                "parameters" => array(
                    "%file%" => basename($file),
                )
            );
            throw new RuntimeException(json_encode($exception));
        }
        self::unlockFile($handle);
    }