| Conditions | 7 |
| Paths | 44 |
| Total Lines | 59 |
| Code Lines | 33 |
| 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 |
||
| 84 | protected function execute(InputInterface $input, OutputInterface $output): int |
||
| 85 | { |
||
| 86 | $io = new SymfonyStyle($input, $output); |
||
| 87 | |||
| 88 | (new PhpSettingsHandler(new ConsoleLogger($output)))->check(); |
||
| 89 | |||
| 90 | $paths = [ |
||
| 91 | $input->getArgument(self::FIRST_PHAR_ARG), |
||
| 92 | $input->getArgument(self::SECOND_PHAR_ARG), |
||
| 93 | ]; |
||
| 94 | |||
| 95 | Assertion::allFile($paths); |
||
|
|
|||
| 96 | |||
| 97 | $tmpFiles = []; |
||
| 98 | |||
| 99 | try { |
||
| 100 | $diff = new PharDiff( |
||
| 101 | ...array_map( |
||
| 102 | function (string $path) use (&$tmpFiles): Pharaoh { |
||
| 103 | $path = false !== realpath($path) ? realpath($path) : $path; |
||
| 104 | |||
| 105 | $tmpPath = $this->createTemporaryPhar($path); |
||
| 106 | |||
| 107 | if ($path !== $tmpPath) { |
||
| 108 | $tmpFiles[] = $tmpPath; |
||
| 109 | } |
||
| 110 | |||
| 111 | return new Pharaoh($tmpPath); |
||
| 112 | }, |
||
| 113 | $paths |
||
| 114 | ) |
||
| 115 | ); |
||
| 116 | $diff->setVerbose(true); |
||
| 117 | } catch (Throwable $throwable) { |
||
| 118 | if ($output->isDebug()) { |
||
| 119 | throw $throwable; |
||
| 120 | } |
||
| 121 | |||
| 122 | $io->writeln( |
||
| 123 | sprintf( |
||
| 124 | '<error>Could not check the PHARs: %s</error>', |
||
| 125 | $throwable->getMessage() |
||
| 126 | ) |
||
| 127 | ); |
||
| 128 | |||
| 129 | return 1; |
||
| 130 | } finally { |
||
| 131 | remove($tmpFiles); |
||
| 132 | } |
||
| 133 | |||
| 134 | if ($input->hasParameterOption(['-c', '--check'])) { |
||
| 135 | return $diff->listChecksums($input->getOption(self::CHECK_OPTION) ?? 'sha384'); |
||
| 136 | } |
||
| 137 | |||
| 138 | if ($input->getOption(self::GNU_DIFF_OPTION)) { |
||
| 139 | return $diff->printGnuDiff(); |
||
| 140 | } |
||
| 141 | |||
| 142 | return $diff->printGitDiff(); |
||
| 143 | } |
||
| 145 |