<commit_before><?php
/**
 * DronePHP (http://www.dronephp.com)
 *
 * @link      http://github.com/Pleets/DronePHP
 * @copyright Copyright (c) 2016-2017 Pleets. (http://www.pleets.org)
 * @license   http://www.dronephp.com/license
 */

namespace Drone\Mvc;

use Drone\LayoutManager\Layout;
use Drone\Mvc\PageNotFoundException;
use Exception;

abstract class AbstractionController
{
    /**
     * Current module
     *
     * @var string
     */
    private $module;

    /**
     * Current method
     *
     * @var string
     */
    private $method = null;

    /**
     * Current parameters
     *
     * @var string
     */
    private $params;

    /**
     * Layout name
     *
     * @var string
     */
    private $layout = "default";

    /**
     * Terminal mode
     *
     * @var boolean
     */
    private $terminal = false;

    /**
     * Returns the current module
     *
     * @return string
     */
    public function getModule()
    {
        return $this->module;
    }

    /**
     * Returns the current method
     *
     * @return string
     */
    public function getMethod()
    {
        return $this->method;
    }

    /**
     * Returns the mode of visualization
     *
     * @return boolean
     */
    public function getTerminal()
    {
        return $this->terminal;
    }

    /**
     * Returns the current layout
     *
     * @return string
     */
    public function getLayout()
    {
        return $this->layout;
    }

    /**
     * Returns all parameters
     *
     * @return string
     */
    public function getParams()
    {
        return $this->params;
    }

    /**
     * Returns the class name
     *
     * @return string
     */
    public static function getClassName()
    {
        return __CLASS__;
    }

    /**
     * Returns $_POST variable, event json encoded (php://input)
     *
     * @return array
     */
    public function getPost()
    {
        if ($_SERVER['REQUEST_METHOD'] == 'POST' && empty($_POST))
            $_POST = json_decode(file_get_contents('php://input'), true);

        return $_POST;
    }

    /**
     * Returns json contents
     *
     * @return array
     */
    public function getJson()
    {
        if ($_SERVER['REQUEST_METHOD'] != 'JSON')
            throw new Exception("Request method is not JSON");

        $input =  file_get_contents('php://input');
        $array = explode("&", $input);

        $result = array();

        foreach ($array as $value)
        {
            $io = explode("=", $value);
            $result[$io[0]] = $io[1];
        }

        return $result;
    }<commit_msg>Fix array return value<commit_after><?php
/**
 * DronePHP (http://www.dronephp.com)
 *
 * @link      http://github.com/Pleets/DronePHP
 * @copyright Copyright (c) 2016-2017 Pleets. (http://www.pleets.org)
 * @license   http://www.dronephp.com/license
 */

namespace Drone\Mvc;

use Drone\LayoutManager\Layout;
use Drone\Mvc\PageNotFoundException;
use Exception;

abstract class AbstractionController
{
    /**
     * Current module
     *
     * @var string
     */
    private $module;

    /**
     * Current method
     *
     * @var string
     */
    private $method = null;

    /**
     * Current parameters
     *
     * @var string
     */
    private $params;

    /**
     * Layout name
     *
     * @var string
     */
    private $layout = "default";

    /**
     * Terminal mode
     *
     * @var boolean
     */
    private $terminal = false;

    /**
     * Returns the current module
     *
     * @return string
     */
    public function getModule()
    {
        return $this->module;
    }

    /**
     * Returns the current method
     *
     * @return string
     */
    public function getMethod()
    {
        return $this->method;
    }

    /**
     * Returns the mode of visualization
     *
     * @return boolean
     */
    public function getTerminal()
    {
        return $this->terminal;
    }

    /**
     * Returns the current layout
     *
     * @return string
     */
    public function getLayout()
    {
        return $this->layout;
    }

    /**
     * Returns all parameters
     *
     * @return string
     */
    public function getParams()
    {
        return $this->params;
    }

    /**
     * Returns the class name
     *
     * @return string
     */
    public static function getClassName()
    {
        return __CLASS__;
    }

    /**
     * Returns $_POST contents
     *
     * @return array
     */
    public function getPost()
    {
        if ($_SERVER['REQUEST_METHOD'] == 'POST' && empty($_POST))
            $_POST = json_decode(file_get_contents('php://input'), true);

        return (array) $_POST;
    }

    /**
     * Returns json contents
     *
     * @return array
     */
    public function getJson()
    {
        if ($_SERVER['REQUEST_METHOD'] != 'JSON')
            throw new Exception("Request method is not JSON");

        $input =  file_get_contents('php://input');
        $array = explode("&", $input);

        $result = array();

        foreach ($array as $value)
        {
            $io = explode("=", $value);
            $result[$io[0]] = $io[1];
        }

        return $result;
    }
{'fraction_non_alphanumeric': 0.1341533730540073, 'fraction_numerical': 0.003843936190659235, 'mean_word_length': 1.642965972574911, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 13, 'https://': 0, 'lorem ipsum': 0, 'www.': 6, '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': '908436', 'n_tokens_mistral': 1582, 'n_tokens_neox': 1530, 'n_words': 362}