<commit_before><?php

/**
 * This file is part of the Flownode package
 *
 * (c) <NAME> <<EMAIL>>
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */
namespace Flownode\Babel\Formatter\Tcpdf;

/**
 *
 * @author <NAME> <<EMAIL>>
 */
class GridFormatter
{
  /**
   *
   * @var Flownode\Babel\Formatter\Html\Formatter;
   */
  protected $formatter;

  protected $rowDecorator = null;

  /**
   *
   * @var array
   */
  protected $columns = array();

  protected $datas;

  protected $columnWidth = array();
  protected $rowHeight   = array();

  protected $width  = 0;
  protected $height = 0;

  /**
   *
   * @param \Flownode\Babel\Formatter\Tcpdf\Formatter $formatter
   * @param array $columns
   * @param array $datas
   */
  public function __construct(Formatter $formatter, $columns, $datas)
  {
    $this->formatter = $formatter;
    $this->columns = $columns;
    $this->datas   = $datas;
  }

  /**
   * Build headers
   * @return void
   */
  public function addHeaders()
  {
    $formatter = $this->formatter->getContent();

    $this->computeOptimalSizes();
    $this->padding = (205 - $this->width) / 2;
    $formatter->setX($this->padding);
    foreach($this->columns as $i => $column)
    {
      $formatter->MultiCell($this->columnWidth[$i], 0, $column->getName(), 0, '', false, 0);
    }

    $formatter->Ln($formatter->getLastH());

  }

  /**
   * Build rows
   * @return void
   */
  public function addRows()
  {
    $formatter = $this->formatter->getContent();

    $formatter->setX($this->padding);

    foreach($this->datas as $r => $row)
    {
      if(null !== $decorator = $this->rowDecorator)
      {
        $decorator($row, $r, $this->formatter);
      }

      foreach($this->columns as $c => $column)
      {
        $value = $column->getValue($row);
        $columnDecorator = $column->getColumnDecorator();
        if($columnDecorator instanceof \Closure)
        {

        }
        else
        {

        }
<commit_msg>Adding column decorator support<commit_after><?php

/**
 * This file is part of the Flownode package
 *
 * (c) <NAME> <<EMAIL>>
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */
namespace Flownode\Babel\Formatter\Tcpdf;

/**
 *
 * @author <NAME> <<EMAIL>>
 */
class GridFormatter
{
  /**
   *
   * @var Flownode\Babel\Formatter\Html\Formatter;
   */
  protected $formatter;

  protected $rowDecorator = null;

  /**
   *
   * @var array
   */
  protected $columns = array();

  protected $datas;

  protected $columnWidth = array();
  protected $rowHeight   = array();

  protected $width  = 0;
  protected $height = 0;

  /**
   *
   * @param \Flownode\Babel\Formatter\Tcpdf\Formatter $formatter
   * @param array $columns
   * @param array $datas
   */
  public function __construct(Formatter $formatter, $columns, $datas)
  {
    $this->formatter = $formatter;
    $this->columns = $columns;
    $this->datas   = $datas;
  }

  /**
   * Build headers
   * @return void
   */
  public function addHeaders()
  {
    $formatter = $this->formatter->getContent();

    $this->computeOptimalSizes();
    $this->padding = (205 - $this->width) / 2;
    $formatter->setX($this->padding);
    foreach($this->columns as $i => $column)
    {
      $formatter->MultiCell($this->columnWidth[$i], 0, $column->getName(), 0, '', false, 0);
    }

    $formatter->Ln($formatter->getLastH());

  }

  /**
   * Build rows
   * @return void
   */
  public function addRows()
  {
    $formatter = $this->formatter->getContent();

    $formatter->setX($this->padding);

    foreach($this->datas as $r => $row)
    {
      if(null !== $decorator = $this->rowDecorator)
      {
        $decorator($row, $r, $this->formatter);
      }

      foreach($this->columns as $c => $column)
      {
        $value = $column->getValue($row);
        $columnDecorator = $column->getColumnDecorator();
        if($columnDecorator instanceof \Closure)
        {
          $columnDecorator($row, $column, $this->formatter);
        }

{'fraction_non_alphanumeric': 0.16480582524271845, 'fraction_numerical': 0.004368932038834952, 'mean_word_length': 2.682752457551385, 'pattern_counts': {'":': 0, '<': 17, '<?xml version=': 0, '>': 74, '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': '4818595', 'n_tokens_mistral': 1398, 'n_tokens_neox': 1309, 'n_words': 291}