/** * @param Result $result */ public function output(Result $result) { if ($result->getAssumptionsCount() > 0) { $this->cli->table($result->getAssumptions())->br(); } $this->cli->out(sprintf('%d out of %d boolean expressions are assumptions (%d%%)', $result->getAssumptionsCount(), $result->getBoolExpressionsCount(), $result->getPercentage())); }
/** * @param $results * @param $pary * @param $list * @param $max_len */ public function exec($results, $pary, $list, $max_len) { $output = []; foreach ($results as $precentage => $result_list) { foreach ($result_list as $id => $result) { $output[] = ['simlarity' => number_format($result['simlarity'], 2) . '%', 'difference' => number_format($result['difference'], 2) . '%', 'Side A' => $result['a'], 'Side B' => $result['b']]; } } $this->climate->table($output); }
/** * @test */ public function itShouldAnalyseTargetDirectory() { $files = [fixture('MyClass.php'), fixture('MyOtherClass.php'), fixture('Example.php')]; $this->argumentManager->get('format')->shouldBeCalled()->willReturn('pretty'); $this->argumentManager->get('path')->shouldBeCalled()->willReturn(FIXTURES_DIR); // Assert that all files show up in the table $this->climate->table(Argument::that(function ($table) use($files) { foreach ($table as $row) { unset($files[array_search($row['file'], $files)]); } return count($files) === 0; }))->shouldBeCalled()->willReturn($this->climate); $this->climate->out(Argument::containingString('boolean expressions are assumptions'))->shouldBeCalled(); $this->cli->handle(['phpa', FIXTURES_DIR]); }
/** * Outputs all the available implementation for the given type (such as Exporters) * Unfortunately most of these have to be hardcoded because of autoloading (otherwise we'd use reflection) */ private function showList() { $type = $this->climate->arguments->get('list'); $data = []; if ($type == 'exporters') { $data = [['name' => 'Void', 'description' => 'Does not output anything even if parsing is done. Pretty much useless.'], ['name' => '<bold>StdOut</bold>', 'description' => '<bold>Prints all the data, formatted in a human-readable format, to the standard output.</bold>'], ['name' => 'File', 'description' => 'Writes each game in its own file using the same human-readable format as StdOut'], ['name' => 'CSV', 'description' => 'Writes each game to its own file in the comma-separated-values format'], ['name' => 'MySQL', 'description' => 'Creates the appropriate tables and inserts the data in a MySQL database'], ['name' => 'MySQL-Dump', 'description' => 'Creates a MySQL .sql file with all the required statements to create a database']]; } if (!empty($data)) { $this->climate->table($data); } }
/** * Render list of registered tasks */ public function actionList() { $this->importScheduleFile(); $climate = new CLImate(); $data = []; $row = 0; foreach ($this->schedule->getEvents() as $event) { $data[] = ['#' => ++$row, 'Task' => $event->getDescription(), 'Expression' => $event->getExpression(), 'Command to Run' => $event->command]; } $climate->table($data); }
/** * Format and Output the result to the console */ private function cliOutput() { $table = [['<green>Package</green>', '<green>Version</green>', '<green>Test</green>', '<green>Avg Duration (MS)</green>']]; foreach ($this->results as $package => $bench) { $package_info = $this->packages->get($package); $index = 0; foreach ($bench as $action => $res) { $infos = [$package, $package_info['version'], $action, round(array_sum(array_column($res, 'duration')) / $this->iteration, 2)]; if (0 == $index % 2) { array_walk($infos, function (&$value) { $value = "<cyan>{$value}</cyan>"; }); } ++$index; $table[] = $infos; } } $this->terminal->table($table); }
/** * @return int|null|void */ protected function serve() { $this->options = $this->input->getOptions(); $this->gpm = new GPM($this->options['force']); $this->displayGPMRelease(); $this->data = $this->gpm->getRepository(); $data = $this->filter($this->data); $climate = new CLImate(); $climate->extend('Grav\\Console\\TerminalObjects\\Table'); if (!$data) { $this->output->writeln('No data was found in the GPM repository stored locally.'); $this->output->writeln('Please try clearing cache and running the <green>bin/gpm index -f</green> command again'); $this->output->writeln('If this doesn\'t work try tweaking your GPM system settings.'); $this->output->writeln(''); $this->output->writeln('For more help go to:'); $this->output->writeln(' -> <yellow>https://learn.getgrav.org/troubleshooting/common-problems#cannot-connect-to-the-gpm</yellow>'); die; } foreach ($data as $type => $packages) { $this->output->writeln("<green>" . strtoupper($type) . "</green> [ " . count($packages) . " ]"); $packages = $this->sort($packages); if (!empty($packages)) { $table = []; $index = 0; foreach ($packages as $slug => $package) { $row = ['Count' => $index++ + 1, 'Name' => "<cyan>" . Utils::truncate($package->name, 20, false, ' ', '...') . "</cyan> ", 'Slug' => $slug, 'Version' => $this->version($package), 'Installed' => $this->installed($package)]; $table[] = $row; } $climate->table($table); } $this->output->writeln(''); } $this->output->writeln('You can either get more informations about a package by typing:'); $this->output->writeln(' <green>' . $this->argv . ' info <cyan><package></cyan></green>'); $this->output->writeln(''); $this->output->writeln('Or you can install a package by typing:'); $this->output->writeln(' <green>' . $this->argv . ' install <cyan><package></cyan></green>'); $this->output->writeln(''); }
/** * Returns CLImate table * @see http://climate.thephpleague.com/terminal-objects/table/ * * @param array $array Table data * @return mixed */ public function table(array $array) { return $this->climate->table($array); }