borderless() public static method

A borderless style.
public static borderless ( ) : TableStyle
return TableStyle The style.
Exemplo n.º 1
0
 public function handleList(Args $args, IO $io)
 {
     $table = new Table(TableStyle::borderless());
     foreach ($this->installerManager->getInstallerDescriptors() as $descriptor) {
         $className = $descriptor->getClassName();
         if (!$args->isOptionSet('long')) {
             $className = StringUtil::getShortClassName($className);
         }
         $parameters = array();
         foreach ($descriptor->getParameters() as $parameterName => $parameter) {
             if (!$parameter->isRequired()) {
                 $parameterName .= '=' . StringUtil::formatValue($parameter->getDefaultValue());
             }
             $parameters[] = $parameterName;
         }
         $description = $descriptor->getDescription();
         if ($parameters) {
             // non-breaking space
             $description .= ' <c1>(' . implode(", ", $parameters) . ')</c1>';
         }
         $table->addRow(array('<u>' . $descriptor->getName() . '</u>', '<c1>' . $className . '</c1>', $description));
     }
     $table->render($io);
     return 0;
 }
Exemplo n.º 2
0
    public function testRenderNoBorder()
    {
        $table = new Table(TableStyle::borderless());
        $table->setHeaderRow(array('ISBN', 'Title', 'Author'));
        $table->addRows(array(array('99921-58-10-7', 'Divine Comedy', 'Dante Alighieri'), array('9971-5-0210-0', 'A Tale of Two Cities', 'Charles Dickens'), array('960-425-059-0', 'The Lord of the Rings', 'J. R. R. Tolkien'), array('80-902734-1-6', 'And Then There Were None', 'Agatha Christie')));
        $table->render($this->io);
        $expected = <<<'EOF'
ISBN          Title                    Author
============= ======================== ================
99921-58-10-7 Divine Comedy            Dante Alighieri
9971-5-0210-0 A Tale of Two Cities     Charles Dickens
960-425-059-0 The Lord of the Rings    J. R. R. Tolkien
80-902734-1-6 And Then There Were None Agatha Christie

EOF;
        $this->assertSame($expected, $this->io->fetchOutput());
    }
Exemplo n.º 3
0
 public function handleList(Args $args, IO $io)
 {
     $table = new Table(TableStyle::borderless());
     $targets = $this->targetManager->getTargets();
     if ($targets->isEmpty()) {
         $io->writeLine('No install targets. Use "puli target add <name> <directory>" to add a target.');
         return 0;
     }
     $defaultTarget = $targets->getDefaultTarget();
     foreach ($targets as $target) {
         $parameters = '';
         foreach ($target->getParameterValues() as $name => $value) {
             $parameters .= "\n<c1>" . $name . '=' . StringUtil::formatValue($value) . '</c1>';
         }
         $table->addRow(array($defaultTarget === $target ? '*' : '', '<u>' . $target->getName() . '</u>', $target->getInstallerName(), '<c2>' . $target->getLocation() . '</c2>' . $parameters, '<c1>' . $target->getUrlFormat() . '</c1>'));
     }
     $table->render($io);
     return 0;
 }
Exemplo n.º 4
0
 /**
  * Prints the resources in the long style (with the "-l" option).
  *
  * @param IO                 $io        The I/O.
  * @param ResourceCollection $resources The resources.
  */
 private function listLong(IO $io, ResourceCollection $resources)
 {
     $style = TableStyle::borderless();
     $style->setColumnAlignments(array(Alignment::LEFT, Alignment::RIGHT, Alignment::LEFT, Alignment::RIGHT, Alignment::RIGHT, Alignment::LEFT));
     $table = new Table($style);
     $today = new DateTime();
     $currentYear = (int) $today->format('Y');
     foreach ($resources as $resource) {
         // Create date from timestamp. Result is in the UTC timezone.
         $modifiedAt = new DateTime('@' . $resource->getMetadata()->getModificationTime());
         // Set timezone to server timezone.
         $modifiedAt->setTimezone($today->getTimezone());
         $year = (int) $modifiedAt->format('Y');
         $table->addRow(array(StringUtil::getShortClassName(get_class($resource)), $this->formatSize($resource->getMetadata()->getSize()), $modifiedAt->format('M'), $modifiedAt->format('j'), $year < $currentYear ? $year : $modifiedAt->format('H:i'), $this->formatName($resource)));
     }
     $table->render($io);
 }
Exemplo n.º 5
0
 /**
  * Prints the given resources.
  *
  * @param IO       $io      The I/O.
  * @param string[] $matches An array of short resource class names indexed
  *                          by the resource path.
  */
 private function printTable(IO $io, array $matches)
 {
     $table = new Table(TableStyle::borderless());
     foreach ($matches as $path => $shortClass) {
         $table->addRow(array($shortClass, "<c1>{$path}</c1>"));
     }
     $table->render($io);
 }
Exemplo n.º 6
0
 /**
  * @param IO             $io
  * @param AssetMapping[] $mappings
  * @param bool           $enabled
  */
 private function printMappingTable(IO $io, array $mappings, $enabled = true)
 {
     $table = new Table(TableStyle::borderless());
     $globTag = $enabled ? 'c1' : 'bad';
     $pathTag = $enabled ? 'c2' : 'bad';
     foreach ($mappings as $mapping) {
         $uuid = substr($mapping->getUuid()->toString(), 0, 6);
         $glob = $mapping->getGlob();
         $serverPath = $mapping->getServerPath();
         if (!$enabled) {
             $uuid = "<bad>{$uuid}</bad>";
         }
         $table->addRow(array($uuid, "<{$globTag}>{$glob}</{$globTag}>", "<{$pathTag}>{$serverPath}</{$pathTag}>"));
     }
     $table->render($io, 8);
 }
Exemplo n.º 7
0
 /**
  * Prints not-loadable packages in a table.
  *
  * @param IO        $io       The I/O.
  * @param Package[] $packages The not-loadable packages.
  * @param bool      $indent   Whether to indent the output.
  */
 private function printNotLoadablePackages(IO $io, array $packages, $indent = false)
 {
     $rootDir = $this->packageManager->getEnvironment()->getRootDirectory();
     $table = new Table(TableStyle::borderless());
     ksort($packages);
     foreach ($packages as $package) {
         $packageName = $package->getName();
         $loadErrors = $package->getLoadErrors();
         $errorMessage = '';
         foreach ($loadErrors as $loadError) {
             $errorMessage .= StringUtil::getShortClassName(get_class($loadError)) . ': ' . $loadError->getMessage() . "\n";
         }
         $errorMessage = rtrim($errorMessage);
         if (!$errorMessage) {
             $errorMessage = 'Unknown error.';
         }
         // Remove root directory
         $errorMessage = str_replace($rootDir . '/', '', $errorMessage);
         $table->addRow(array("<bad>{$packageName}</bad>:", "<bad>{$errorMessage}</bad>"));
     }
     $table->render($io, $indent ? 4 : 0);
 }
Exemplo n.º 8
0
 /**
  * @param IO             $io
  * @param AssetMapping[] $mappings
  * @param bool           $enabled
  */
 private function printMappingTable(IO $io, array $mappings, $enabled = true)
 {
     $table = new Table(TableStyle::borderless());
     $globTag = $enabled ? 'c1' : 'bad';
     $pathTag = $enabled ? 'c2' : 'bad';
     foreach ($mappings as $mapping) {
         $uuid = substr($mapping->getUuid()->toString(), 0, 6);
         $glob = $mapping->getGlob();
         $serverPath = $mapping->getServerPath();
         if (!$enabled) {
             $uuid = sprintf('<bad>%s</bad>', $uuid);
         }
         $table->addRow(array($uuid, sprintf('<%s>%s</%s>', $globTag, $glob, $globTag), sprintf('<%s>%s</%s>', $pathTag, $serverPath, $pathTag)));
     }
     $table->render($io, 8);
 }
Exemplo n.º 9
0
 /**
  * @param MigrationsStatusCommand $command
  */
 public function migrationsStatus(MigrationsStatusCommand $command)
 {
     try {
         $status = $this->migrator->status();
         $latestMigration = $status->latestMigration();
         $rows = array(array(' Current Version', $latestMigration ? sprintf('<c2>%s (%s)</c2>', $latestMigration->version()->__toString(), $latestMigration->createdAt()->format('Y-m-d H:i:s')) : '<c2>0</c2>'), array(' Latest Version', $status->latestAvailableVersion() ? '<c2>' . $status->latestAvailableVersion()->__toString() . '</c2>' : '<c2>none</c2>'), array(' Next Version', $status->nextAvailableVersion() ? '<c2>' . $status->nextAvailableVersion()->__toString() . '</c2>' : '<c2>none</c2>'), array(' Executed Migrations', '<c2>' . $status->numExecutedMigrations() . '</c2>'), array(' Available Migrations', '<c2>' . $status->numAvailableMigrations() . '</c2>'), array(' New Migrations', '<c2>' . $status->numNewMigrations() . '</c2>'));
         $table = new Table(TableStyle::borderless());
         foreach ($rows as $row) {
             $table->addRow($row);
         }
         $table->render($command->getIo());
     } catch (\Exception $e) {
         $command->getIo()->writeLine('<error>' . $e->getMessage() . '</error>');
     }
 }