SensioLabs\Insight\Cli\Helper\DescriptorHelper::describe PHP Method

describe() public method

public describe ( Symfony\Component\Console\Output\OutputInterface $output, $object, $format = null, $showIgnoredViolation = false )
$output Symfony\Component\Console\Output\OutputInterface
    public function describe(OutputInterface $output, $object, $format = null, $showIgnoredViolation = false)
    {
        $options = array('raw_text' => false, 'format' => $format ?: 'txt', 'output' => $output, 'show_ignored_violations' => $showIgnoredViolation);
        $options['type'] = 'txt' === $options['format'] ? OutputInterface::OUTPUT_NORMAL : OutputInterface::OUTPUT_RAW;
        if (!isset($this->descriptors[$options['format']])) {
            throw new \InvalidArgumentException(sprintf('Unsupported format "%s".', $options['format']));
        }
        $this->descriptors[$options['format']]->describe($object, $options);
    }

Usage Example

Example #1
0
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $projectUuid = $input->getArgument('project-uuid');
     $api = $this->getApplication()->getApi();
     $analysis = $api->analyze($projectUuid, $input->getOption('reference'));
     $chars = array('-', '\\', '|', '/');
     $position = 0;
     while (true) {
         // we don't check the status too often
         if (0 == $position % 2) {
             $analysis = $api->getAnalysisStatus($projectUuid, $analysis->getNumber());
         }
         if ('txt' === $input->getOption('format')) {
             $output->write(sprintf("%s %-80s\r", $chars[$position % 4], $analysis->getStatusMessage()));
         }
         if ($analysis->isFinished()) {
             break;
         }
         usleep(200000);
         ++$position;
     }
     $analysis = $api->getAnalysis($projectUuid, $analysis->getNumber());
     if ($analysis->isFailed()) {
         $output->writeln(sprintf('There was an error: "%s"', $analysis->getFailureMessage()));
         return 1;
     }
     $helper = new DescriptorHelper($api->getSerializer());
     $helper->describe($output, $analysis, $input->getOption('format'), $input->getOption('show-ignored-violations'));
     if ('txt' === $input->getOption('format') && OutputInterface::VERBOSITY_VERBOSE > $output->getVerbosity()) {
         $output->writeln('');
         $output->writeln(sprintf('Run <comment>%s %s %s -v</comment> to get the full report', $_SERVER['PHP_SELF'], 'analysis', $projectUuid));
     }
 }
All Usage Examples Of SensioLabs\Insight\Cli\Helper\DescriptorHelper::describe