Conditions | 5 |
Total Lines | 59 |
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); |
||
1 ignored issue
–
show
|
|||
96 | |||
97 | try { |
||
98 | $diff = new PharDiff( |
||
99 | ...array_map( |
||
100 | function (string $path): Pharaoh { |
||
101 | $path = false !== realpath($path) ? realpath($path) : $path; |
||
102 | |||
103 | return new class($path) extends Pharaoh { |
||
104 | // TODO: remove this once https://github.com/paragonie/pharaoh/pull/9 is merged |
||
105 | public function __destruct() |
||
106 | { |
||
107 | $path = $this->phar->getPath(); |
||
108 | |||
109 | unset($this->phar); |
||
110 | |||
111 | \Phar::unlinkArchive($path); |
||
112 | } |
||
113 | }; |
||
114 | }, |
||
115 | $paths |
||
116 | ) |
||
117 | ); |
||
118 | $diff->setVerbose(true); |
||
119 | } catch (Throwable $throwable) { |
||
120 | if ($output->isDebug()) { |
||
121 | throw $throwable; |
||
122 | } |
||
123 | |||
124 | $io->writeln( |
||
125 | sprintf( |
||
126 | '<error>Could not check the PHARs: %s</error>', |
||
127 | $throwable->getMessage() |
||
128 | ) |
||
129 | ); |
||
130 | |||
131 | return 1; |
||
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 |