setName('talk:active-calls') ->setDescription('Allows you to check if calls are currently in process') ; } protected function execute(InputInterface $input, OutputInterface $output): int { $numCalls = $this->metricsService->getNumberOfActiveCalls(); if ($numCalls === 0) { if ($input->getOption('output') === 'plain') { $output->writeln('No calls in progress'); } else { $data = ['calls' => 0, 'participants' => 0]; $this->writeArrayInOutputFormat($input, $output, $data); } return 0; } $numSessions = $this->metricsService->getNumberOfSessionsInCalls(); // We keep "participants" here, to not break scripting done with that command if ($input->getOption('output') === 'plain') { $output->writeln(sprintf('There are currently %1$d calls in progress with %2$d participants', $numCalls, $numSessions)); } else { $data = ['calls' => $numCalls, 'participants' => $numSessions]; $this->writeArrayInOutputFormat($input, $output, $data); } return 1; } }