<commit_before><?php
/*
 * This file is part of the Logger package.
 *
 * (c) Anekdotes Communication inc. <<EMAIL>>
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */

namespace Anekdotes\FormWrapper;

/**
 * Controller class in charge of receiving calls and dispatching them.
 */
class Form
{
    /**
     * Calls the desired control, prepare it and pass it to a wrapper.
     *
     * @param string $name      The name of the called function. Represents the Control class to be used
     * @param array  $arguments The passed arguments to the function
     *                          [0]  string    $title  Field's title, to potentially be displayed in a label.
     *                          [x]            $args   All arguments to be passed to the control
     *                          [-1]  string   $wrap   Name of the wrapper class to be used
     */
    public function __call($name, $arguments)
    {
        $args = array_slice($arguments, 1, count($arguments) - 1);
        $title = $arguments[0];
        $controlStr = 'Anekdotes\\FormWrapper\\Controls\\'.$name;
        $control = new $controlStr();
        $prepared = $control->prepare($args);
        $wrapStr = $this->obtainWrapperName($control, $arguments);
        $wrap = new $wrapStr();

        return $wrap->handle($title, $prepared);
    }

    private function obtainWrapperName($control, $arguments)
    {
        $currentWrapper = 'None';
        $wrapperNameSpace = 'Anekdotes\\FormWrapper\\Wrappers\\';
        $nbParams = $control->getNbParams();
        //We have normally have x+2 $arguments ('title' and 'wrap'). If we're missing wrap , we'll have x+1
        if ($nbParams < count($arguments) - 1) {
            end($arguments);
            $currentWrapper = current($arguments);<commit_msg>Fixed issue where a param wouldn't be passed<commit_after><?php
/*
 * This file is part of the Logger package.
 *
 * (c) Anekdotes Communication inc. <<EMAIL>>
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */

namespace Anekdotes\FormWrapper;

/**
 * Controller class in charge of receiving calls and dispatching them.
 */
class Form
{
    /**
     * Calls the desired control, prepare it and pass it to a wrapper.
     *
     * @param string $name      The name of the called function. Represents the Control class to be used
     * @param array  $arguments The passed arguments to the function
     *                          [0]  string    $title  Field's title, to potentially be displayed in a label.
     *                          [x]            $args   All arguments to be passed to the control
     *                          [-1]  string   $wrap   Name of the wrapper class to be used
     */
    public function __call($name, $arguments)
    {
        $title = $arguments[0];
        $controlStr = 'Anekdotes\\FormWrapper\\Controls\\'.$name;
        $control = new $controlStr();
        $slice = $control->getNbParams() < count($arguments) - 1 ? 0 : 1;
        $args = array_slice($arguments, 1, count($arguments) - $slice);
        $prepared = $control->prepare($args);
        $wrapStr = $this->obtainWrapperName($control, $arguments);
        $wrap = new $wrapStr();

        return $wrap->handle($title, $prepared);
    }

    private function obtainWrapperName($control, $arguments)
    {
        $currentWrapper = 'None';
        $wrapperNameSpace = 'Anekdotes\\FormWrapper\\Wrappers\\';
        $nbParams = $control->getNbParams();
        //We have normally have x+2 $arguments ('title' and 'wrap'). If we're missing wrap , we'll have x+1
        if ($nbParams < count($arguments) - 1) {
            end($arguments);
            $currentWrapper = current($arguments);
{'fraction_non_alphanumeric': 0.11398017736045905, 'fraction_numerical': 0.004694835680751174, 'mean_word_length': 2.3261058109280137, 'pattern_counts': {'":': 0, '<': 12, '<?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': 6, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3588623', 'n_tokens_mistral': 1042, 'n_tokens_neox': 1022, 'n_words': 366}