<commit_before><?php

namespace Xport;

use Xport\MappingReader\MappingReader;
use Xport\SpreadsheetModel\Cell;
use Xport\SpreadsheetModel\Column;
use Xport\SpreadsheetModel\Parser\ForEachParser;
use Xport\SpreadsheetModel\Parser\ParsingException;
use Xport\SpreadsheetModel\Parser\Scope;
use Xport\SpreadsheetModel\Parser\TwigParser;
use Xport\SpreadsheetModel\SpreadsheetModel;
use Xport\SpreadsheetModel\Line;
use Xport\SpreadsheetModel\Sheet;
use Xport\SpreadsheetModel\Table;

/**
 * Builds a Spreadsheet model
 *
 * @author <NAME> <<EMAIL>>
 */
class SpreadsheetModelBuilder
{
    /**
     * @var Scope
     */
    private $scope;
    /**
     * @var ForEachParser
     */
    private $forEachParser;
    /**
     * @var TwigParser
     */
    private $twigParser;

    public function __construct()
    {
        $this->scope = new Scope();
        $this->forEachParser = new ForEachParser();
        $this->twigParser = new TwigParser();
    }

    /**
     * Bind a value to a name.
     *
     * @param string $name
     * @param mixed  $value
     */
    public function bind($name, $value)
    {
        $this->scope->bind($name, $value);
    }

    /**
     * Build a model.
     *
     * @param MappingReader $mappingReader
     * @throws ParsingException
     * @return SpreadsheetModel
     */
    public function build(MappingReader $mappingReader)
    {
        $model = new SpreadsheetModel();
        $this->parseRoot($model, $mappingReader->getMapping(), $this->scope);

        return $model;
    }

    private function parseRoot(SpreadsheetModel $model, $yamlRoot, Scope $scope)<commit_msg>Ajout du bind des fonctions sur le ModelBuilder<commit_after><?php

namespace Xport;

use Xport\MappingReader\MappingReader;
use Xport\SpreadsheetModel\Cell;
use Xport\SpreadsheetModel\Column;
use Xport\SpreadsheetModel\Parser\ForEachParser;
use Xport\SpreadsheetModel\Parser\ParsingException;
use Xport\SpreadsheetModel\Parser\Scope;
use Xport\SpreadsheetModel\Parser\TwigParser;
use Xport\SpreadsheetModel\SpreadsheetModel;
use Xport\SpreadsheetModel\Line;
use Xport\SpreadsheetModel\Sheet;
use Xport\SpreadsheetModel\Table;

/**
 * Builds a Spreadsheet model
 *
 * @author <NAME> <<EMAIL>>
 */
class SpreadsheetModelBuilder
{
    /**
     * @var Scope
     */
    private $scope;
    /**
     * @var ForEachParser
     */
    private $forEachParser;
    /**
     * @var TwigParser
     */
    private $twigParser;

    public function __construct()
    {
        $this->scope = new Scope();
        $this->forEachParser = new ForEachParser();
        $this->twigParser = new TwigParser();
    }

    /**
     * Bind a value to a name.
     *
     * @param string $name
     * @param mixed  $value
     */
    public function bind($name, $value)
    {
        $this->scope->bind($name, $value);
    }

    /**
     * Bind a function to a name.
     *
     * @param string   $name
     * @param callable $callable
     */
    public function bindFunction($name, $callable)
    {
        $this->scope->bindFunction($name, $callable);
    }

    /**
     * Build a model.
     *
     * @param MappingReader $mappingReader
     * @throws ParsingException
     * @return SpreadsheetModel
     */
    public function build(MappingReader $mappingReader)
    {
        $model = new SpreadsheetModel();
        $this->parseRoot($model, $mappingReader->getMapping(), $this->scope);

        return $model;
    }

    private function parseRoot(SpreadsheetModel $model, $yamlRoot, Scope $scope)
{'fraction_non_alphanumeric': 0.12003429551300372, 'fraction_numerical': 0.0, 'mean_word_length': 2.791982665222102, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 27, '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': '6597509', 'n_tokens_mistral': 1107, 'n_tokens_neox': 1088, 'n_words': 234}