|
| 1 | +<?php |
| 2 | + |
| 3 | +declare(strict_types=1); |
| 4 | + |
| 5 | +/* |
| 6 | + * This file is part of Ymir command-line tool. |
| 7 | + * |
| 8 | + * (c) Carl Alexander <support@ymirapp.com> |
| 9 | + * |
| 10 | + * For the full copyright and license information, please view the LICENSE |
| 11 | + * file that was distributed with this source code. |
| 12 | + */ |
| 13 | + |
| 14 | +namespace Ymir\Cli\Command\Php; |
| 15 | + |
| 16 | +use Symfony\Component\Console\Input\InputInterface; |
| 17 | +use Symfony\Component\Console\Input\InputOption; |
| 18 | +use Ymir\Cli\Command\AbstractInvocationCommand; |
| 19 | +use Ymir\Cli\Console\OutputStyle; |
| 20 | + |
| 21 | +class PhpVersionCommand extends AbstractInvocationCommand |
| 22 | +{ |
| 23 | + /** |
| 24 | + * The name of the command. |
| 25 | + * |
| 26 | + * @var string |
| 27 | + */ |
| 28 | + public const NAME = 'php:version'; |
| 29 | + |
| 30 | + /** |
| 31 | + * {@inheritdoc} |
| 32 | + */ |
| 33 | + protected function configure() |
| 34 | + { |
| 35 | + $this |
| 36 | + ->setName(self::NAME) |
| 37 | + ->setDescription('Get information about PHP version on the cloud provider') |
| 38 | + ->addOption('environment', null, InputOption::VALUE_REQUIRED, 'The environment name', 'staging'); |
| 39 | + } |
| 40 | + |
| 41 | + /** |
| 42 | + * {@inheritdoc} |
| 43 | + */ |
| 44 | + protected function perform(InputInterface $input, OutputStyle $output) |
| 45 | + { |
| 46 | + $environment = (string) $this->getStringOption($input, 'environment'); |
| 47 | + |
| 48 | + $output->info(sprintf('Get information about the PHP version from the "<comment>%s</comment>" environment', $environment)); |
| 49 | + |
| 50 | + $result = $this->invokeEnvironmentFunction($environment, [ |
| 51 | + 'php' => '--version', |
| 52 | + ]); |
| 53 | + |
| 54 | + $output->newLine(); |
| 55 | + $output->write("${result['output']}"); |
| 56 | + |
| 57 | + return $result['exitCode']; |
| 58 | + } |
| 59 | +} |
0 commit comments