| Total Complexity | 4 |
| Total Lines | 63 |
| Duplicated Lines | 0 % |
| Coverage | 94.44% |
| Changes | 0 | ||
| 1 | <?php |
||
| 12 | abstract class AbstractCommand extends ContainerAwareCommand |
||
| 13 | { |
||
| 14 | /** |
||
| 15 | * @var InputInterface |
||
| 16 | */ |
||
| 17 | protected $input; |
||
| 18 | |||
| 19 | /** |
||
| 20 | * @var OutputInterface |
||
| 21 | */ |
||
| 22 | protected $output; |
||
| 23 | |||
| 24 | /** |
||
| 25 | * {@inheritdoc} |
||
| 26 | */ |
||
| 27 | 3 | protected function configure() |
|
| 28 | { |
||
| 29 | 3 | $this->addArgument( |
|
| 30 | 3 | 'id', |
|
| 31 | 3 | InputArgument::REQUIRED, |
|
| 32 | 3 | 'Subscription ID' |
|
| 33 | ); |
||
| 34 | 3 | } |
|
| 35 | |||
| 36 | /** |
||
| 37 | * {@inheritdoc} |
||
| 38 | */ |
||
| 39 | 3 | protected function execute(InputInterface $input, OutputInterface $output) |
|
| 40 | { |
||
| 41 | // Save the input interfaces |
||
| 42 | 3 | $this->input = $input; |
|
| 43 | 3 | $this->output = $output; |
|
| 44 | |||
| 45 | 3 | $subscriptionId = $input->getArgument('id'); |
|
| 46 | 3 | $subscription = $this->getContainer()->get('terox.subscription.repository.subscription')->findById($subscriptionId); |
|
| 47 | |||
| 48 | 3 | if(null === $subscription) { |
|
| 49 | return $output->writeln(sprintf('<error>The subscription with ID "%s" was not found.</error>', $subscriptionId)); |
||
| 50 | } |
||
| 51 | |||
| 52 | // Execute the action |
||
| 53 | 3 | $this->action($subscription); |
|
| 54 | |||
| 55 | 3 | $output->writeln('<green>Finished.</green>'); |
|
| 56 | 3 | } |
|
| 57 | |||
| 58 | /** |
||
| 59 | * Action to execute when |
||
| 60 | * |
||
| 61 | * @param SubscriptionInterface $subscription |
||
| 62 | * |
||
| 63 | * @return void |
||
| 64 | */ |
||
| 65 | abstract protected function action(SubscriptionInterface $subscription); |
||
| 66 | |||
| 67 | /** |
||
| 68 | * Get SubscriptionManager. |
||
| 69 | * |
||
| 70 | * @return SubscriptionManager |
||
| 71 | */ |
||
| 72 | 3 | protected function getManager() |
|
| 75 | } |
||
| 76 | } |
||
| 77 |