1 | <?php |
||||
2 | |||||
3 | namespace Lamoda\Metric\MetricBundle\Command; |
||||
4 | |||||
5 | use Lamoda\Metric\Storage\Exception\ReceiverException; |
||||
6 | use Lamoda\Metric\Storage\MaterializeHelper; |
||||
7 | use Symfony\Component\Console\Command\Command; |
||||
8 | use Symfony\Component\Console\Input\InputArgument; |
||||
9 | use Symfony\Component\Console\Input\InputInterface; |
||||
10 | use Symfony\Component\Console\Output\OutputInterface; |
||||
11 | use Symfony\Component\Console\Style\SymfonyStyle; |
||||
12 | |||||
13 | final class MaterializeMetricsCommand extends Command |
||||
14 | { |
||||
15 | protected static $defaultName = 'metrics:materialize'; |
||||
16 | |||||
17 | /** |
||||
18 | * @var MaterializeHelper |
||||
19 | */ |
||||
20 | private $helper; |
||||
21 | |||||
22 | public function __construct(MaterializeHelper $helper) |
||||
23 | { |
||||
24 | parent::__construct(); |
||||
25 | $this->helper = $helper; |
||||
26 | } |
||||
27 | |||||
28 | protected function configure(): void |
||||
29 | { |
||||
30 | $this->addArgument('collector', InputArgument::REQUIRED, 'Collector name from configuration'); |
||||
31 | $this->addArgument('storage', InputArgument::REQUIRED, 'Storage name from configuration'); |
||||
32 | } |
||||
33 | |||||
34 | protected function execute(InputInterface $input, OutputInterface $output): ?int |
||||
35 | { |
||||
36 | $io = new SymfonyStyle($input, $output); |
||||
37 | |||||
38 | $collector = $input->getArgument('collector'); |
||||
39 | $storage = $input->getArgument('storage'); |
||||
40 | |||||
41 | try { |
||||
42 | $this->helper->materialize($collector, $storage); |
||||
0 ignored issues
–
show
Bug
introduced
by
![]() It seems like
$storage can also be of type null and string[] ; however, parameter $storageName of Lamoda\Metric\Storage\Ma...zeHelper::materialize() does only seem to accept string , maybe add an additional type check?
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
![]() |
|||||
43 | |||||
44 | return 0; |
||||
45 | } catch (\OutOfBoundsException $exception) { |
||||
46 | $io->error('Invalid argument supplied'); |
||||
47 | } catch (ReceiverException $exception) { |
||||
48 | $io->error('Failed to receive metrics in storage: ' . $exception->getMessage()); |
||||
49 | } |
||||
50 | |||||
51 | return -1; |
||||
52 | } |
||||
53 | } |
||||
54 |