Platformsh\Cli\Util\Table::renderSimple PHP Method

renderSimple() public method

Render an single-dimensional array of values, with their property names.
public renderSimple ( array $values, array $propertyNames )
$values array
$propertyNames array
    public function renderSimple(array $values, array $propertyNames)
    {
        $data = [];
        foreach ($propertyNames as $key => $label) {
            $data[] = [$label, $values[$key]];
        }
        $this->render($data, ['Property', 'Value']);
    }

Usage Example

 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;
 }
All Usage Examples Of Platformsh\Cli\Util\Table::renderSimple