PaypalController   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 27
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 5

Importance

Changes 0
Metric Value
wmc 2
lcom 1
cbo 5
dl 0
loc 27
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A webhookAction() 0 9 1
1
<?php
2
3
/**
4
 * @author    Markus Tacker <[email protected]>
5
 * @copyright 2013-2016 Verein zur Förderung der Netzkultur im Rhein-Main-Gebiet e.V. | http://netzkultur-rheinmain.de/
6
 */
7
8
namespace BCRM\WebBundle\Controller;
9
10
use BCRM\BackendBundle\Service\Event\CreatePaymentCommand;
11
use LiteCQRS\Bus\CommandBus;
12
use Symfony\Component\HttpFoundation\Request;
13
use Symfony\Component\HttpFoundation\Response;
14
15
/**
16
 * Manages Paypal webhooks notifications
17
 */
18
class PaypalController
19
{
20
    /**
21
     * @var \LiteCQRS\Bus\CommandBus
22
     */
23
    private $commandBus;
24
25
    public function __construct(CommandBus $commandBus)
26
    {
27
        $this->commandBus = $commandBus;
28
    }
29
30
    /**
31
     * @param Request $request
32
     *
33
     * @return Response
34
     */
35
    public function webhookAction(Request $request)
36
    {
37
        $command          = new CreatePaymentCommand();
38
        $command->payload = $request->request->all();
39
        $command->txId    = $command->payload['txn_id'];
40
        $command->method  = 'paypal';
41
        $this->commandBus->handle($command);
42
        return new Response();
43
    }
44
}
45