| Conditions | 10 | 
| Paths | 24 | 
| Total Lines | 47 | 
| Code Lines | 29 | 
| Lines | 0 | 
| Ratio | 0 % | 
| Changes | 0 | ||
Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.
For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.
Commonly applied refactorings include:
If many parameters/temporary variables are present:
| 1 | <?php  | 
            ||
| 33 | protected function execute(InputInterface $input, OutputInterface $output)  | 
            ||
| 34 |     { | 
            ||
| 35 |         $json = json_decode(file_get_contents($input->getArgument('input')[0]), true); | 
            ||
| 36 | |||
| 37 | $output->writeln(sprintf(  | 
            ||
| 38 | "Date: <info>%s</info> Formatter: <info>%s</info>, Comment: <info>%s</info>",  | 
            ||
| 39 |             date('d.m.Y H:i:s', $json['timestamp']), $json['formatter'], isset($json['comment']) ? $json['comment'] : 'none' | 
            ||
| 40 | ));  | 
            ||
| 41 | |||
| 42 | $table = new Table($output);  | 
            ||
| 43 | |||
| 44 |         $suffix = $input->getOption('relative') ? 'bytes/s' : 'ms'; | 
            ||
| 45 | $table->addRow(['set', "min [$suffix]", "avg [$suffix]", "max [$suffix]", "std dev [$suffix]"]);  | 
            ||
| 46 | |||
| 47 | $summary = [];  | 
            ||
| 48 |         foreach ($json['results'] as $file => $data) { | 
            ||
| 49 | $this->separator($file, $table);  | 
            ||
| 50 | |||
| 51 |             foreach ($data['times'] as $set => $times) { | 
            ||
| 52 |                 $result = array_map(function ($time) use ($data, $input) { | 
            ||
| 53 |                     return $input->getOption('relative') ? $data['size'] / $time : $time * 1000; | 
            ||
| 54 | }, $times);  | 
            ||
| 55 | |||
| 56 | $this->entry($result, $set, $table);  | 
            ||
| 57 | |||
| 58 | $summary[$set][] = array_sum($result) / count($result);  | 
            ||
| 59 | }  | 
            ||
| 60 | }  | 
            ||
| 61 | |||
| 62 |         if(!$input->hasOption('summary')) { | 
            ||
| 63 | $table->render();  | 
            ||
| 64 | }  | 
            ||
| 65 | |||
| 66 |         $summary = array_filter($summary, function($key) use ($input) { | 
            ||
| 67 |             return fnmatch($input->getOption('summary') ?: '*', $key); | 
            ||
| 68 | }, ARRAY_FILTER_USE_KEY);  | 
            ||
| 69 | |||
| 70 |         $max = max(array_map('strlen', array_keys($summary))); | 
            ||
| 71 |         foreach($summary as $name => $set) { | 
            ||
| 72 | $output->writeln(sprintf(  | 
            ||
| 73 | "<comment>%s</comment> %s %s",  | 
            ||
| 74 | str_pad($name, $max, ' ', STR_PAD_LEFT),  | 
            ||
| 75 |                 $this->format($input->getOption('relative') ? array_sum($set) / count($set) : array_sum($set)), | 
            ||
| 76 | $suffix  | 
            ||
| 77 | ));  | 
            ||
| 78 | }  | 
            ||
| 79 | }  | 
            ||
| 80 | |||
| 135 |