renderSimple() public method

Render an single-dimensional array of values, with their property names.
public renderSimple ( array $values, array $propertyNames )
$values array
$propertyNames array
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $info = $this->api()->getMyAccount((bool) $input->getOption('refresh'));
     $formatter = new PropertyFormatter($input);
     $propertyWhitelist = ['id', 'uuid', 'display_name', 'username', 'mail', 'has_key'];
     $info = array_intersect_key($info, array_flip($propertyWhitelist));
     $property = $input->getArgument('property');
     if ($input->getOption('property')) {
         if ($property) {
             throw new InvalidArgumentException(sprintf('You cannot use both the <%s> argument and the --%s option', 'property', 'property'));
         }
         $property = $input->getOption('property');
     }
     if ($property) {
         if (!isset($info[$property])) {
             throw new \InvalidArgumentException('Property not found: ' . $property);
         }
         $output->writeln($formatter->format($info[$property], $property));
         return 0;
     }
     unset($info['uuid']);
     $values = [];
     $header = [];
     foreach ($propertyWhitelist as $property) {
         if (isset($info[$property])) {
             $values[] = $formatter->format($info[$property], $property);
             $header[] = $property;
         }
     }
     $table = new Table($input, $output);
     $table->renderSimple($values, $header);
     return 0;
 }
 /**
  * @param Environment $environment
  *
  * @param Table       $table
  *
  * @return int
  */
 protected function listProperties(Environment $environment, Table $table)
 {
     $headings = [];
     $values = [];
     foreach ($environment->getProperties() as $key => $value) {
         $headings[] = new AdaptiveTableCell($key, ['wrap' => false]);
         $values[] = $this->formatter->format($value, $key);
     }
     $table->renderSimple($values, $headings);
     return 0;
 }
 /**
  * @param Integration     $integration
  * @param InputInterface  $input
  * @param OutputInterface $output
  */
 protected function displayIntegration(Integration $integration, InputInterface $input, OutputInterface $output)
 {
     $table = new Table($input, $output);
     $info = [];
     foreach ($integration->getProperties() as $property => $value) {
         $info[$property] = $this->propertyFormatter->format($value, $property);
     }
     if ($integration->hasLink('#hook')) {
         $info['hook_url'] = $this->propertyFormatter->format($integration->getLink('#hook'));
     }
     $table->renderSimple(array_values($info), array_keys($info));
 }
 /**
  * @param Subscription $subscription
  * @param Table        $table
  *
  * @return int
  */
 protected function listProperties(Subscription $subscription, Table $table)
 {
     $headings = [];
     $values = [];
     foreach ($subscription->getProperties() as $key => $value) {
         $value = $this->formatter->format($value, $key);
         $value = wordwrap($value, 50, "\n", true);
         $headings[] = $key;
         $values[] = $value;
     }
     $table->renderSimple($values, $headings);
     return 0;
 }
 /**
  * {@inheritdoc}
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $this->validateInput($input);
     $project = $this->getSelectedProject();
     $domainName = $input->getArgument('name');
     if (empty($domainName)) {
         if (!$input->isInteractive()) {
             $this->stdErr->writeln('The domain name is required.');
             return 1;
         }
         $domains = $project->getDomains();
         $options = [];
         foreach ($domains as $domain) {
             $options[$domain->name] = $domain->name;
         }
         /** @var QuestionHelper $questionHelper */
         $questionHelper = $this->getHelper('question');
         $domainName = $questionHelper->choose($options, 'Enter a number to choose a domain:');
     }
     $domain = $project->getDomain($domainName);
     if (!$domain) {
         $this->stdErr->writeln('Domain not found: <error>' . $domainName . '</error>');
         return 1;
     }
     $propertyFormatter = new PropertyFormatter($input);
     if ($property = $input->getOption('property')) {
         $value = $this->api()->getNestedProperty($domain, $property);
         $output->writeln($propertyFormatter->format($value, $property));
         return 0;
     }
     $values = [];
     $properties = [];
     foreach ($domain->getProperties() as $name => $value) {
         // Hide the deprecated (irrelevant) property 'wildcard'.
         if ($name === 'wildcard') {
             continue;
         }
         $properties[] = $name;
         $values[] = $propertyFormatter->format($value, $name);
     }
     $table = new Table($input, $output);
     $table->renderSimple($values, $properties);
     $this->stdErr->writeln('');
     $this->stdErr->writeln('To update a domain, run: <info>' . self::$config->get('application.executable') . ' domain:update [domain-name]</info>');
     $this->stdErr->writeln('To delete a domain, run: <info>' . self::$config->get('application.executable') . ' domain:delete [domain-name]</info>');
     return 0;
 }
 /**
  * @param Project $project
  * @param Table   $table
  *
  * @return int
  */
 protected function listProperties(Project $project, Table $table)
 {
     // Properties not to display, as they are internal, deprecated, or
     // otherwise confusing.
     $blacklist = ['name', 'cluster', 'cluster_label', 'license_id', 'plan', '_endpoint', 'repository', 'subscription'];
     $headings = [];
     $values = [];
     foreach ($project->getProperties() as $key => $value) {
         if (!in_array($key, $blacklist)) {
             $value = $this->formatter->format($value, $key);
             $value = wordwrap($value, 50, "\n", true);
             $headings[] = $key;
             $values[] = $value;
         }
     }
     $table->renderSimple($values, $headings);
     return 0;
 }
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $this->validateInput($input);
     $projectRoot = $this->getProjectRoot();
     if (!$projectRoot) {
         throw new RootNotFoundException();
     }
     $appName = $this->selectApp($input);
     $sshUrl = $this->getSelectedEnvironment()->getSshUrl($appName);
     // Get and parse app config.
     $app = LocalApplication::getApplication($appName, $projectRoot);
     $appConfig = $app->getConfig();
     if (empty($appConfig['relationships'])) {
         $this->stdErr->writeln('No application relationships found.');
         return 1;
     }
     $util = new RelationshipsUtil($this->stdErr);
     $database = $util->chooseDatabase($sshUrl, $input);
     if (empty($database)) {
         $this->stdErr->writeln('No database selected.');
         return 1;
     }
     // Find the database's service name in the relationships.
     $dbServiceName = false;
     foreach ($appConfig['relationships'] as $relationshipName => $relationship) {
         if ($database['_relationship_name'] === $relationshipName) {
             list($dbServiceName, ) = explode(':', $relationship, 2);
             break;
         }
     }
     if (!$dbServiceName) {
         $this->stdErr->writeln('Service name not found for relationship: ' . $database['_relationship_name']);
         return 1;
     }
     // Load services yaml.
     $services = Yaml::parse(file_get_contents($projectRoot . '/.platform/services.yaml'));
     if (!empty($services[$dbServiceName]['disk'])) {
         $allocatedDisk = $services[$dbServiceName]['disk'];
     } else {
         $this->stdErr->writeln('The allocated disk size could not be determined for service: ' . $dbServiceName);
         return 1;
     }
     $this->stdErr->write('Querying database <comment>' . $dbServiceName . '</comment> to estimate disk usage. ');
     $this->stdErr->writeln('This might take a while.');
     /** @var ShellHelper $shellHelper */
     $shellHelper = $this->getHelper('shell');
     $command = ['ssh'];
     $command[] = $sshUrl;
     switch ($database['scheme']) {
         case 'pgsql':
             $command[] = $this->psqlQuery($database);
             $result = $shellHelper->execute($command);
             $resultArr = explode(PHP_EOL, $result);
             $estimatedUsage = array_sum($resultArr) / 1048576;
             break;
         default:
             $command[] = $this->mysqlQuery($database);
             $estimatedUsage = $shellHelper->execute($command);
             break;
     }
     $percentsUsed = $estimatedUsage * 100 / $allocatedDisk;
     $table = new Table($input, $output);
     $propertyNames = ['max', 'used', 'percent_used'];
     $machineReadable = $table->formatIsMachineReadable();
     $values = [(int) $allocatedDisk . ($machineReadable ? '' : 'MB'), (int) $estimatedUsage . ($machineReadable ? '' : 'MB'), (int) $percentsUsed . '%'];
     $table->renderSimple($values, $propertyNames);
     return 0;
 }