Passed
Push — main ( 413103...4ffc18 )
by Iain
05:47
created

RequestProcessor   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 18
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 7
c 1
b 0
f 0
dl 0
loc 18
rs 10
wmc 2

2 Methods

Rating   Name   Duplication   Size   Complexity  
A processRequest() 0 9 1
A __construct() 0 5 1
1
<?php
2
3
declare(strict_types=1);
4
5
/*
6
 * Copyright Iain Cambridge 2020-2023.
7
 *
8
 * Use of this software is governed by the Business Source License included in the LICENSE file and at https://getparthenon.com/docs/next/license.
9
 *
10
 * Change Date: TBD ( 3 years after 2.2.0 release )
11
 *
12
 * On the date above, in accordance with the Business Source License, use of this software will be governed by the open source license specified in the LICENSE file.
13
 */
14
15
namespace Parthenon\Billing\Webhook;
16
17
use Obol\Model\WebhookPayload;
18
use Obol\Provider\ProviderInterface;
19
use Parthenon\Billing\Config\WebhookConfig;
20
use Symfony\Component\HttpFoundation\Request;
21
22
final class RequestProcessor implements RequestProcessorInterface
23
{
24
    public function __construct(
25
        private WebhookConfig $config,
26
        private ProviderInterface $provider,
27
        private HandlerManagerInterface $handlerManager,
28
    ) {
29
    }
30
31
    public function processRequest(Request $request): void
32
    {
33
        $webhookPayload = new WebhookPayload();
34
        $webhookPayload->setPayload($request->getContent());
35
        $webhookPayload->setSignature($request->get('stripe-signature'));
36
        $webhookPayload->setSecret($this->config->getSecret());
37
38
        $event = $this->provider->webhook()->process($webhookPayload);
39
        $this->handlerManager->handle($event);
0 ignored issues
show
Bug introduced by
It seems like $event can also be of type null; however, parameter $event of Parthenon\Billing\Webhoo...agerInterface::handle() does only seem to accept Obol\Model\Events\EventInterface, 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 ignore-type  annotation

39
        $this->handlerManager->handle(/** @scrutinizer ignore-type */ $event);
Loading history...
40
    }
41
}
42