<commit_before><?php

namespace Arkschools\DataInputSheets;

use Arkschools\DataInputSheets\Bridge\Symfony\Entity\Cell;
use Doctrine\ORM\EntityManager;
use Doctrine\ORM\Mapping\ClassMetadataInfo;
use Symfony\Component\HttpFoundation\Request;

class View
{
    const FORM_NAME = 'DIS';

    /**
     * @var string
     */
    private $sheetId;

    /**
     * @var string
     */
    private $title;

    /**
     * @var string
     */
    private $id;

    /**
     * @var Spine
     */
    private $spine;

    /**
     * @var array
     */
    private $filters;

    /**
     * @var bool
     */
    private $filtersApplied;

    /**
     * @var Column[]
     */
    private $columns;

    /**
     * @var Column[]
     */
    private $visibleColumns;

    /**
     * @var array
     */
    private $objects;

    /**
     * @var mixed
     */
    private $contents;

    /**
     * @var bool
     */
    private $useExternalEntity;

    /**
     * @var bool
     */
    private $useCustomTable = false;

    /**
     * @param string   $sheetId
     * @param string   $title
     * @param Spine    $spine
     * @param array    $spineFilter
     * @param Column[] $columns
     * @param string[] $hiddenColumns
     */
    public function __construct(
        string $sheetId,
        string $title,
        Spine $spine,
        array $spineFilter,
        array $columns,
        array $hiddenColumns = []
    ) {
        $this->sheetId = $sheetId;
        $this->id      = \slugifier\slugify($title);
        $this->title   = $title;
        $this->spine   = $spine;
        $this->filters = $spineFilter;

        $this->useExternalEntity = false;

        if (null !== $spine->getEntity()) {
            $this->useExternalEntity = true;
        }

        $this->useCustomTable = false;

        if (null !== $spine->getTableName()) {
            $this->useCustomTable = true;
        }

        $this->columns = [];

        foreach ($columns as $column) {
            $columnId                 = $column->getId();
            $this->columns[$columnId] = $column;

            if (!isset($hiddenColumns[$columnId])) {
                $this->visibleColumns[$columnId] = $column;
            }

            if ($column->isValueColumn()) {
                foreach (array_keys($spine->getSpine()) as $spineId) {
                    $this->contents[$spineId][$columnId] = $column->getValue($spine->getSpineObject($spineId));
                }
            }
        }
    }

    public function getId(): string
    {
        return $this->id;
    }

    public function getSheetId(): string
    {
        return $this->sheetId;
    }

    public function getTitle(): string
    {
        return $this->title;
    }

    public function getSpineHeader(): string
    {
        return $this->spine->getHeader();
    }

    /**
     * @return string[]
     */
    public function getSpine(): array<commit_msg>Lazy loads view contents<commit_after><?php

namespace Arkschools\DataInputSheets;

use Arkschools\DataInputSheets\Bridge\Symfony\Entity\Cell;
use Doctrine\ORM\EntityManager;
use Doctrine\ORM\Mapping\ClassMetadataInfo;
use Symfony\Component\HttpFoundation\Request;

class View
{
    const FORM_NAME = 'DIS';

    /**
     * @var string
     */
    private $sheetId;

    /**
     * @var string
     */
    private $title;

    /**
     * @var string
     */
    private $id;

    /**
     * @var Spine
     */
    private $spine;

    /**
     * @var array
     */
    private $filters;

    /**
     * @var bool
     */
    private $filtersApplied;

    /**
     * @var Column[]
     */
    private $columns;

    /**
     * @var Column[]
     */
    private $visibleColumns;

    /**
     * @var array
     */
    private $objects;

    /**
     * @var mixed
     */
    private $contents;

    /**
     * @var bool
     */
    private $useExternalEntity;

    /**
     * @var bool
     */
    private $useCustomTable = false;

    /**
     * @param string   $sheetId
     * @param string   $title
     * @param Spine    $spine
     * @param array    $spineFilter
     * @param Column[] $columns
     * @param string[] $hiddenColumns
     */
    public function __construct(
        string $sheetId,
        string $title,
        Spine $spine,
        array $spineFilter,
        array $columns,
        array $hiddenColumns = []
    ) {
        $this->sheetId = $sheetId;
        $this->id      = \slugifier\slugify($title);
        $this->title   = $title;
        $this->spine   = $spine;
        $this->filters = $spineFilter;

        $this->useExternalEntity = false;

        if (null !== $spine->getEntity()) {
            $this->useExternalEntity = true;
        }

        $this->useCustomTable = false;

        if (null !== $spine->getTableName()) {
            $this->useCustomTable = true;
        }

        $this->columns = [];

        foreach ($columns as $column) {
            $columnId                 = $column->getId();
            $this->columns[$columnId] = $column;

            if (!isset($hiddenColumns[$columnId])) {
                $this->visibleColumns[$columnId] = $column;
            }
        }
    }

    public function getId(): string
    {
        return $this->id;
    }

    public function getSheetId(): string
    {
        return $this->sheetId;
    }

    public function getTitle(): string
    {
        return $this->title;
    }

    public function getSpineHeader(): string
    {
        return $this->spine->getHeader();
    }

    /**
     * @return string[]
     */
    public function getSpine(): array
{'fraction_non_alphanumeric': 0.13962264150943396, 'fraction_numerical': 0.0, 'mean_word_length': 1.6644327429392054, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 48, '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': '2791992', 'n_tokens_mistral': 1713, 'n_tokens_neox': 1660, 'n_words': 340}