<commit_before><?php
/**
 * 
 * This file is part of the Aura project for PHP.
 * 
 * @license http://opensource.org/licenses/bsd-license.php BSD
 * 
 */
namespace Aura\Framework;
use Aura\Web\Context;
use Aura\Web\ControllerFactory;
use Aura\Router\Map as RouterMap;

/**
 * 
 * Dispatches a Route to a Controller and returns a ResponseTransfer object.
 * 
 * @package Aura.Framework
 * 
 */
class Dispatcher implements DispatcherInterface
{
    /**
     * 
     * A factory to create web controllers.
     * 
     * @var Aura\Web\ControllerFactory
     * 
     */
    protected $controller_factory;
    
    /**
     * 
     * A router map to dipatch against.
     * 
     * @var Aura\Router\Map
     * 
     */
    protected $router;
    
    /**
     * 
     * Constructor.
     * 
     */
    public function __construct(
        RouterMap         $router,
        ControllerFactory $controller_factory
    ) {
        $this->router             = $router;
        $this->controller_factory = $controller_factory;
    }
    
    /**
     * 
     * Creates and executes a web controller.
     * 
     * @return Aura\Web\ResponseTransfer
     * 
     */
    public function exec($path, array $server = null)
    {
        // match to a route
        $route = $this->router->match($path, $server);
        
        // was there a match?
        if ($route) {
            // retain info
            $controller = $route->values['controller'];
            $params     = $route->values;
        } else {
            // no match
            $controller = null;
            $params     = array();
        }
        
        // create controller
        $obj = $this->controller_factory->newInstance($controller, $params);
        
        // execute and return data transfer object
        return $obj->exec();
    }
}<commit_msg>force $server to an array<commit_after><?php
/**
 * 
 * This file is part of the Aura project for PHP.
 * 
 * @license http://opensource.org/licenses/bsd-license.php BSD
 * 
 */
namespace Aura\Framework;
use Aura\Web\Context;
use Aura\Web\ControllerFactory;
use Aura\Router\Map as RouterMap;

/**
 * 
 * Dispatches a Route to a Controller and returns a ResponseTransfer object.
 * 
 * @package Aura.Framework
 * 
 */
class Dispatcher implements DispatcherInterface
{
    /**
     * 
     * A factory to create web controllers.
     * 
     * @var Aura\Web\ControllerFactory
     * 
     */
    protected $controller_factory;
    
    /**
     * 
     * A router map to dipatch against.
     * 
     * @var Aura\Router\Map
     * 
     */
    protected $router;
    
    /**
     * 
     * Constructor.
     * 
     */
    public function __construct(
        RouterMap         $router,
        ControllerFactory $controller_factory
    ) {
        $this->router             = $router;
        $this->controller_factory = $controller_factory;
    }
    
    /**
     * 
     * Creates and executes a web controller.
     * 
     * @return Aura\Web\ResponseTransfer
     * 
     */
    public function exec($path, array $server = array())
    {
        // match to a route
        $route = $this->router->match($path, $server);
        
        // was there a match?
        if ($route) {
            // retain info
            $controller = $route->values['controller'];
            $params     = $route->values;
        } else {
            // no match
            $controller = null;
            $params     = array();
        }
        
        // create controller
        $obj = $this->controller_factory->newInstance($controller, $params);
        
        // execute and return data transfer object
        return $obj->exec();
    }
}
{'fraction_non_alphanumeric': 0.11480774475047723, 'fraction_numerical': 0.0, 'mean_word_length': 1.6369518332135156, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 21, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1548218', 'n_tokens_mistral': 1064, 'n_tokens_neox': 1018, 'n_words': 256}