<commit_before><?php
namespace API\Controller;

use Zend\Mvc\Controller\AbstractActionController;
use Zend\View\Model\JsonModel;

class IndexController extends AbstractActionController
{
	public function indexAction()
	{
		$error = false;
		$response = false;
		//get config
		$config = $this->getServiceLocator()->get('Config');
		if(! array_key_exists('roach', (array) $config)) {
			throw new \Exception('config.roach not found.');
		}
		$config = (array) $config['roach'];
		if(! array_key_exists('api', (array) $config)) {
			throw new \Exception('config.roach.api not found.');
		}
		$config = (array) $config['api'];
		//get request
		$request = $this->getRequest()->getPOST();
		$method = $request->get('method', '');
		$data = $request->get('data', array());
		//get details current request
		if(array_key_exists($method, $config['methods'])) {
			$item = $config['methods'][$method];
			//check if model is specified
			if(array_key_exists('model', $item)) {
				try {
					$model = $this->getServiceLocator()->get($item['model']);
					//check if model method is specified
					if(array_key_exists('method', $item)) {
						if(method_exists($model, $item['method'])) {
							$response = call_user_func_array(array($model, $item['method']), array());
						} else {<commit_msg>#3 - get method parameters from 'params' key and pass to model->method as first parameter.<commit_after><?php
namespace API\Controller;

use Zend\Mvc\Controller\AbstractActionController;
use Zend\View\Model\JsonModel;

class IndexController extends AbstractActionController
{
	public function indexAction()
	{
		$error = false;
		$response = false;
		//get config
		$config = $this->getServiceLocator()->get('Config');
		if(! array_key_exists('roach', (array) $config)) {
			throw new \Exception('config.roach not found.');
		}
		$config = (array) $config['roach'];
		if(! array_key_exists('api', (array) $config)) {
			throw new \Exception('config.roach.api not found.');
		}
		$config = (array) $config['api'];
		//get request
		$request = $this->getRequest()->getPOST();
		$method = $request->get('method', '');
		$params = $request->get('params', array());
		//get details current request
		if(array_key_exists($method, $config['methods'])) {
			$item = $config['methods'][$method];
			//check if model is specified
			if(array_key_exists('model', $item)) {
				try {
					$model = $this->getServiceLocator()->get($item['model']);
					//check if model method is specified
					if(array_key_exists('method', $item)) {
						if(method_exists($model, $item['method'])) {
							$response = call_user_func_array(array($model, $item['method']), array($params));
						} else {
{'fraction_non_alphanumeric': 0.1831831831831832, 'fraction_numerical': 0.00037537537537537537, 'mean_word_length': 4.506198347107438, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 20, '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': '3830286', 'n_tokens_mistral': 942, 'n_tokens_neox': 831, 'n_words': 189}