<?php

class Request
{
    
// Constructor
    
function Request () {}

    
// Doing the magic
    //   Params:
    //     $mixed -> (string) Name of the Target-Class
    //            -> (object) Context-Object
    
function resolve ($mixed)
    {
        
// If there is nothing to resolve -> return
        
if ($_SERVER['REQUEST_METHOD'] != "POST" &&
            
$_SERVER['REQUEST_METHOD'] != "GET") return;

        
// Create an instance of the target class, because
        // we need it as helper to use the method_exists
        // function
        
$obj = (gettype($mixed) == "string") ? new $mixed $mixed;

        
// Request-Array
        
$requestVars = ($_SERVER['REQUEST_METHOD'] == "GET") ? $_GET $_POST;

        
// Iterate through all request-Variables
        
while (list($key$val) = each($requestVars))
        {
            if (!
method_exists($obj$key)) continue;

            
// Do the magic - call the method
            // with request-Variable-Value as
            // argument
            
call_user_func(array(&$obj$key), $val);
        }
    }
}

/*
Usage:
class BlogReader_Request
{
    function getModificationTime ($test)
    {
        echo "gMT ". $test;
    }
}
// with context-object
//$obj = new Hok_Request;
//Request::resolve($obj);

// with static-class
Request::resolve("BlogReader_Request");
*/

?>