<commit_before><?php

namespace Aidantwoods\Phpmd\Blocks;

use Aidantwoods\Phpmd\Block;
use Aidantwoods\Phpmd\Structure;
use Aidantwoods\Phpmd\Lines\Lines;
use Aidantwoods\Phpmd\Elements\BlockElement;

class Table extends AbstractBlock implements Block
{
    private $columns,
            $tBody;

    protected static $markers = array(
        '-', '|'
    );

    public static function isPresent(Lines $Lines) : bool
    {
        if ($cols = self::tableMarker($Lines->current()))
        {
            # if we have sufficient headings to match marker indicated columns
            if (
                count(
                    self::decomposeTableRow($Lines->lookup($Lines->key() -1))
                ) === $cols
            ) {
                # place the pointer on the heading line

                $Lines->before();

                return true;
            }
        }

        return false;
    }

    public static function begin(Lines $Lines) : ?Block
    {
        $headings = self::decomposeTableRow($Lines->current());

        $Lines->next();

        return new static($headings);
    }

    public function parse(Lines $Lines) : bool
    {<commit_msg>no decompose on null lookup<commit_after><?php

namespace Aidantwoods\Phpmd\Blocks;

use Aidantwoods\Phpmd\Block;
use Aidantwoods\Phpmd\Structure;
use Aidantwoods\Phpmd\Lines\Lines;
use Aidantwoods\Phpmd\Elements\BlockElement;

class Table extends AbstractBlock implements Block
{
    private $columns,
            $tBody;

    protected static $markers = array(
        '-', '|'
    );

    public static function isPresent(Lines $Lines) : bool
    {
        $before = $Lines->lookup($Lines->key() -1) ?? '';

        if ($cols = self::tableMarker($Lines->current()))
        {
            # if we have sufficient headings to match marker indicated columns
            if (count(self::decomposeTableRow($before)) === $cols)
            {
                # place the pointer on the heading line

                $Lines->before();

                return true;
            }
        }

        return false;
    }

    public static function begin(Lines $Lines) : ?Block
    {
        $headings = self::decomposeTableRow($Lines->current());

        $Lines->next();

        return new static($headings);
    }

    public function parse(Lines $Lines) : bool
    {
{'fraction_non_alphanumeric': 0.11396743787489289, 'fraction_numerical': 0.000856898029134533, 'mean_word_length': 2.052287581699346, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 15, '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': '7109446', 'n_tokens_mistral': 682, 'n_tokens_neox': 634, 'n_words': 159}