setColumnMaxWidth example

$this->assertSame($expected$this->getOutputContent($output));
    }

    public function testColumnMaxWidths()
    {
        $table = new Table($output = $this->getOutputStream());
        $table
            ->setRows([
                ['Divine Comedy', 'A Tale of Two Cities', 'The Lord of the Rings', 'And Then There Were None'],
            ])
            ->setColumnMaxWidth(1, 5)
            ->setColumnMaxWidth(2, 10)
            ->setColumnMaxWidth(3, 15);

        $table->render();

        $expected =
            <<<TABLE +---------------+-------+----------+----------------+ | Divine Comedy | A | The Lord | And Then There | | | Tale | of the | Were None | | | of | Rings | | | | Two | | | | | Citie | | | | | s | | | +---------------+-------+----------+----------------+
$io->section($title);
            $io->text('No validators were found for this class.');

            return;
        }

        $io->section($title);

        $table = new Table($output);
        $table->setHeaders(['Property', 'Name', 'Groups', 'Options']);
        $table->setRows($rows);
        $table->setColumnMaxWidth(3, 80);
        $table->render();
    }

    private function getClassConstraintsData(ClassMetadataInterface $classMetadata): iterable
    {
        foreach ($classMetadata->getConstraints() as $constraint) {
            yield [
                'class' => $constraint::class,
                'groups' => $constraint->groups,
                'options' => $this->getConstraintOptions($constraint),
            ];
        }
$io->section($title);
            $io->text('No validators were found for this class.');

            return;
        }

        $io->section($title);

        $table = new Table($output);
        $table->setHeaders(['Property', 'Name', 'Groups', 'Options']);
        $table->setRows($rows);
        $table->setColumnMaxWidth(3, 80);
        $table->render();
    }

    private function getClassConstraintsData(ClassMetadataInterface $classMetadata): iterable
    {
        foreach ($classMetadata->getConstraints() as $constraint) {
            yield [
                'class' => $constraint::class,
                'groups' => $constraint->groups,
                'options' => $this->getConstraintOptions($constraint),
            ];
        }
Home | Imprint | This part of the site doesn't use cookies.