Lines 83.33% 5 / 6
Methods 50.00% 1 / 2
Classes 0.00% 0 / 1
Name Lines Methods CRAP
 __construct 100.00% 1 / 1 100.00% 1 / 1 1
 process 80.00% 4 / 5 0.00% 0 / 1 2.03
19final readonly class TimelineEventProcessor implements ProcessorInterface
20{
21    /**
22     * @param ProcessorInterface<TimelineEvent, TimelineEvent> $persistProcessor
23     */
24    public function __construct(
25        #[Autowire(service: 'api_platform.doctrine.orm.state.persist_processor')]
26        private ProcessorInterface $persistProcessor,
27        private Security $security,
28    ) {
29    }
30
31    public function process(mixed $data, Operation $operation, array $uriVariables = [], array $context = []): TimelineEvent
32    {
33        $user = $this->security->getUser();
34        if (!$user instanceof User) {
35            throw new \LogicException('The operation requires ROLE_USER.');
36        }
37
38        $data->owner = $user;
39
40        return $this->persistProcessor->process($data, $operation, $uriVariables, $context);
41    }
42}