NotifyNullAction   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 31
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 6

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 3
lcom 1
cbo 6
dl 0
loc 31
ccs 12
cts 12
cp 1
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A execute() 0 11 1
A supports() 0 6 2
1
<?php
2
3
namespace PayumTW\Mypay\Action;
4
5
use PayumTW\Mypay\Api;
6
use Payum\Core\Request\Notify;
7
use Payum\Core\Request\GetToken;
8
use Payum\Core\GatewayAwareTrait;
9
use Payum\Core\GatewayAwareInterface;
10
use Payum\Core\Action\ActionInterface;
11
use Payum\Core\Request\GetHttpRequest;
12
use Payum\Core\Exception\RequestNotSupportedException;
13
14
class NotifyNullAction implements ActionInterface, GatewayAwareInterface
15
{
16
    use GatewayAwareTrait;
17
18
    /**
19
     * {@inheritdoc}
20
     *
21
     * @param Notify $request
22
     */
23 1
    public function execute($request)
24
    {
25 1
        RequestNotSupportedException::assertSupports($this, $request);
26 1
        $httpRequest = new GetHttpRequest();
27 1
        $this->gateway->execute($httpRequest);
28
29 1
        $notifyToken = $httpRequest->request[Api::NOTIFY_TOKEN_FIELD];
30 1
        $getToken = new GetToken($notifyToken);
31 1
        $this->gateway->execute($getToken);
32 1
        $this->gateway->execute(new Notify($getToken->getToken()));
33 1
    }
34
35
    /**
36
     * {@inheritdoc}
37
     */
38 1
    public function supports($request)
39
    {
40
        return
41 1
            $request instanceof Notify &&
42 1
            null === $request->getModel();
43
    }
44
}
45