| Conditions | 8 |
| Paths | 54 |
| Total Lines | 66 |
| Code Lines | 38 |
| 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 |
||
| 63 | protected function execute(InputInterface $input, OutputInterface $output): int |
||
| 64 | { |
||
| 65 | $io = new SymfonyStyle($input, $output); |
||
| 66 | |||
| 67 | $pharPath = $input->getArgument(self::PHAR_ARG); |
||
| 68 | |||
| 69 | Assertion::file($pharPath); |
||
| 70 | |||
| 71 | $pharPath = false !== realpath($pharPath) ? realpath($pharPath) : $pharPath; |
||
| 72 | |||
| 73 | $io->writeln( |
||
| 74 | sprintf( |
||
| 75 | 'Verifying the PHAR "<comment>%s</comment>"...', |
||
| 76 | $pharPath |
||
| 77 | ), |
||
| 78 | self::VERBOSITY_LEVEL |
||
| 79 | ); |
||
| 80 | |||
| 81 | try { |
||
| 82 | $phar = new Phar($pharPath); |
||
| 83 | |||
| 84 | $verified = true; |
||
| 85 | $signature = $phar->getSignature(); |
||
| 86 | } catch (Throwable $throwable) { |
||
| 87 | // Continue |
||
| 88 | |||
| 89 | $verified = false; |
||
| 90 | $signature = null; |
||
| 91 | } |
||
| 92 | |||
| 93 | if (false === $verified) { |
||
| 94 | $message = isset($throwable) && '' !== $throwable->getMessage() |
||
| 95 | ? $throwable->getMessage() |
||
| 96 | : 'Unknown reason.' |
||
| 97 | ; |
||
| 98 | |||
| 99 | $io->writeln( |
||
| 100 | sprintf( |
||
| 101 | '<error>The PHAR failed the verification: %s</error>', |
||
| 102 | $message |
||
| 103 | ) |
||
| 104 | ); |
||
| 105 | |||
| 106 | if ($output->isVerbose() && isset($throwable)) { |
||
| 107 | throw $throwable; |
||
| 108 | } |
||
| 109 | |||
| 110 | return 1; |
||
| 111 | } |
||
| 112 | |||
| 113 | $io->writeln('<info>The PHAR passed verification.</info>'); |
||
| 114 | |||
| 115 | $io->writeln( |
||
| 116 | '', |
||
| 117 | self::VERBOSITY_LEVEL |
||
| 118 | ); |
||
| 119 | $io->writeln( |
||
| 120 | sprintf( |
||
| 121 | '%s signature: <info>%s</info>', |
||
| 122 | $signature['hash_type'], |
||
| 123 | $signature['hash'] |
||
| 124 | ), |
||
| 125 | self::VERBOSITY_LEVEL |
||
| 126 | ); |
||
| 127 | |||
| 128 | return 0; |
||
| 129 | } |
||
| 131 |