<commit_before><?php

namespace Yaoi\Cli\View;

use Yaoi\View\Hardcoded;
use Yaoi\View\Semantic\Renderer;
use Yaoi\View\Semantic\Text;

class Table extends Hardcoded implements Renderer
{
    private $colDelimiter = '   ';
    private $rowDelimiter = null;
    /** @var \Iterator  */
    private $rows;

    public function __construct(\Iterator $rows)
    {
        $this->rows = $rows;
    }

    public function setColDelimiter($delimiter = '   ') {
        $this->colDelimiter = $delimiter;
        return $this;
    }

    public function setRowDelimiter($delimiter = null) {
        $this->rowDelimiter = $delimiter;
        return $this;
    }

    public function render()
    {

        $length = array();
        $rowDelimiterLine = null;
        $lines = array();

        foreach ($this->rows as $rowIndex => $row) {
            foreach ($row as $key => $value) {
                if (!$value instanceof Text) {
                    $value = new Text($value);
                }
                $renderer = new \Yaoi\Cli\View\Text($value);
                foreach ($renderer->lines() as $lineIndex => $line) {
                    $stringLength = strlen($line->text->value);
                    if (!isset($length[$key]) || $length[$key] < $stringLength) {
                        $length[$key] = $stringLength;
                    }
                    $lines [$rowIndex][$lineIndex][$key] = $line;
                }
            }
        }


        foreach ($lines as $rowIndex => $rowData) {
            foreach ($rowData as $lineIndex => $row) {
                $line = '';
                foreach ($length as $key => $maxLength) {
                    /** @var \Yaoi\Cli\View\Text $value */
                    $value = isset($row[$key]) ? $row[$key] : null;

                    if ($line) {
                        $line .= $this->colDelimiter;
                    }
                    if ($value) {
                        $value->strPad($maxLength);
                        $line .= $value;<commit_msg>Fatal error: Cannot use Yaoi\View\Semantic\Text as Text because the name is already in use in vendor/php-yaoi/php-yaoi/src/Cli/View/Table.php on line 7<commit_after><?php

namespace Yaoi\Cli\View;

use Yaoi\View\Hardcoded;
use Yaoi\View\Semantic\Renderer;
use Yaoi\View\Semantic;

class Table extends Hardcoded implements Renderer
{
    private $colDelimiter = '   ';
    private $rowDelimiter = null;
    /** @var \Iterator  */
    private $rows;

    public function __construct(\Iterator $rows)
    {
        $this->rows = $rows;
    }

    public function setColDelimiter($delimiter = '   ') {
        $this->colDelimiter = $delimiter;
        return $this;
    }

    public function setRowDelimiter($delimiter = null) {
        $this->rowDelimiter = $delimiter;
        return $this;
    }

    public function render()
    {

        $length = array();
        $rowDelimiterLine = null;
        $lines = array();

        foreach ($this->rows as $rowIndex => $row) {
            foreach ($row as $key => $value) {
                if (!$value instanceof Semantic\Text) {
                    $value = new Semantic\Text($value);
                }
                $renderer = new Text($value);
                foreach ($renderer->lines() as $lineIndex => $line) {
                    $stringLength = strlen($line->text->value);
                    if (!isset($length[$key]) || $length[$key] < $stringLength) {
                        $length[$key] = $stringLength;
                    }
                    $lines [$rowIndex][$lineIndex][$key] = $line;
                }
            }
        }


        foreach ($lines as $rowIndex => $rowData) {
            foreach ($rowData as $lineIndex => $row) {
                $line = '';
                foreach ($length as $key => $maxLength) {
                    /** @var \Yaoi\Cli\View\Text $value */
                    $value = isset($row[$key]) ? $row[$key] : null;

                    if ($line) {
                        $line .= $this->colDelimiter;
                    }
                    if ($value) {
                        $value->strPad($maxLength);
                        $line .= $value;
{'fraction_non_alphanumeric': 0.13745210727969348, 'fraction_numerical': 0.00023946360153256704, 'mean_word_length': 1.507202881152461, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 33, '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': '4190146', 'n_tokens_mistral': 1198, 'n_tokens_neox': 1154, 'n_words': 262}