Issues (48)

Handler/MetricsHandler.php (1 issue)

Labels
Severity
1
<?php
2
3
declare(strict_types=1);
4
5
/**
6
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
7
 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
8
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
9
 *
10
 * Copyright (c) 2024 Mykhailo Shtanko [email protected]
11
 *
12
 * For the full copyright and license information, please view the LICENSE.MD
13
 * file that was distributed with this source code.
14
 */
15
16
namespace FRZB\Component\MetricsPower\Handler;
17
18
use FRZB\Component\DependencyInjection\Attribute\AsService;
19
use FRZB\Component\MetricsPower\Helper\MetricalHelper;
20
use FRZB\Component\MetricsPower\OptionsResolver\OptionsResolverLocatorInterface;
21
use Symfony\Component\Messenger\Event\AbstractWorkerMessageEvent;
22
use Symfony\Component\Messenger\Event\SendMessageToTransportsEvent;
23
24
#[AsService]
25
class MetricsHandler implements MetricsHandlerInterface
26
{
27
    public function __construct(
28
        private readonly OptionsResolverLocatorInterface $locator,
29
    ) {
30
    }
31
32
    public function handle(AbstractWorkerMessageEvent|SendMessageToTransportsEvent $event): void
33
    {
34
        foreach (MetricalHelper::getOptions($event->getEnvelope()->getMessage()) as $options) {
35
            $this->locator->get($options)->resolve($event, $options);
0 ignored issues
show
The method resolve() does not exist on FRZB\Component\MetricsPo...ptionsResolverInterface. Since it exists in all sub-types, consider adding an abstract or default implementation to FRZB\Component\MetricsPo...ptionsResolverInterface. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

35
            $this->locator->get($options)->/** @scrutinizer ignore-call */ resolve($event, $options);
Loading history...
36
        }
37
    }
38
}
39