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