<commit_before><?php 

namespace App\Core\Controller;

use App\Core\DependencyInjection\ContainerInterface;
use App\Core\DependencyInjection\ContainerAwareInterface;
use App\Core\Controller\Exception\MethodNotFoundException;

class ControllerResolver
{
    /**
     * Container
     * @var ContainerInterface
     */
    protected $container;

    /**
     * Name
     * @var string
     */
    protected $name;

    public function __construct(ContainerInterface $container)
    {
        $this->container = $container;
    }

    /**
     * Create the controller and return the action
     * 
     * @return array Controller & method
     */
    public function getAction($name)
    {
        $controllerParams = explode('@', $name);

        $controller = $this->container->resolve('App\Controller\\' . $controllerParams[0]);

        if (!method_exists($controller, $controllerParams[1])) {
            throw new MethodNotFoundException($controllerParams[1]);
        }

        if ($controller instanceof ContainerAwareInterface) {
            $controller->setContainer($this->container);
        }

        return array($controller, $controllerParams[1]);
    }
}<commit_msg>Update ControllerResolver.php<commit_after><?php 
namespace App\Core\Controller;
use App\Core\DependencyInjection\ContainerInterface;
use App\Core\DependencyInjection\ContainerAwareInterface;
use App\Core\DependencyInjection\Exception\ServiceNotFoundException;
use App\Core\Controller\Exception\MethodNotFoundException;
class ControllerResolver
{
    /**
     * Container
     * @var ContainerInterface
     */
    protected $container;
    public function __construct(ContainerInterface $container)
    {
        $this->container = $container;
    }
    /**
     * Create the controller and return the action
     * 
     * @return array Controller & method
     */
    public function getAction($name)
    {
        list($controller, $method) = explode('@', $name);
        try {  
            $controller = $this->container->resolve('App\Controller\\' . $controller);
        } catch (ServiceNotFoundException $e) {
            $filePath = ROOT . 'app/Controller/' . $controller . '.php';
            if (file_exists($filePath)) {
                include_once($filePath);
                $controllerName = 'App\Controller\\' . $controller;
                $controller = new $controllerName($this->container);
                $this->container->register($controllerName, $controller);
            } else {
                throw $e; 
            }
        }
        if (!method_exists($controller, $method)) {
            throw new MethodNotFoundException($method);
        }
        if ($controller instanceof ContainerAwareInterface) {
            $controller->setContainer($this->container);
        }
        return array($controller, $method);
    }
}
{'fraction_non_alphanumeric': 0.11772999647514981, 'fraction_numerical': 0.0014099400775467042, 'mean_word_length': 2.5743073047858944, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 16, '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': '812319', 'n_tokens_mistral': 718, 'n_tokens_neox': 702, 'n_words': 144}