Example #1
0
/**
 * Processes the request to build a response.
 *
 * @param $routes  array
 * @param $options array
 * @return string
 */
function run(array $routes, array $options = [])
{
    $paramSet = isset($options['param_set']) ? $options['param_set'] : [];
    $params = Request\prepareParams($paramSet);
    $request = Request\parse($params);
    $response = Response\create();
    $pipeline = wrapPipeline($request, $routes, $options);
    return Util\pipe($pipeline, ['request' => $request, 'response' => $response]);
}
Example #2
0
 public function testPipeFunctionAdditionalArguments()
 {
     $f1 = function ($current, $arg) {
         return $arg;
     };
     $pipeline = [[$f1, array('f1')]];
     $initial = null;
     $result = Util\pipe($pipeline, $initial);
     $this->assertNotEquals($result, $initial);
     $this->assertEquals($result, 'f1');
 }