TransfersController::searchTransfer()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
cc 1
eloc 3
c 1
b 0
f 1
nc 1
nop 0
dl 0
loc 5
rs 10
1
<?php
2
3
namespace App\Controller\Hyperwallet;
4
5
use Hyperwallet\Exception\HyperwalletApiException;
6
use Symfony\Component\HttpFoundation\Request;
7
use Symfony\Component\Routing\Annotation\Route;
8
use Symfony\Component\HttpFoundation\Response;
9
10
/**
11
 * Class TransfersController
12
 * @package App\Controller\Hyperwallet
13
 *
14
 * @Route("/hyperwallet/transfers", name="hyperwallet-transfers-")
15
 */
16
class TransfersController extends AbstractController
17
{
18
    /**
19
     * @Route("/", name="index", methods={"GET"})
20
     *
21
     * @return Response
22
     */
23
    public function index(): Response
24
    {
25
        return $this->render('hyperwallet/transfers/index.html.twig');
26
    }
27
28
    /**
29
     * @Route("/create", name="create-get", methods={"GET"})
30
     *
31
     * @return Response
32
     */
33
    public function createTransferGet(): Response
34
    {
35
        return $this->render('hyperwallet/transfers/create.html.twig');
36
    }
37
38
    /**
39
     * @Route("/create", name="create-post", methods={"POST"})
40
     *
41
     * @return Response
42
     */
43
    public function createTransferPost(): Response
44
    {
45
        $request = Request::createFromGlobals();
46
        $transferDetails = $request->request->all();
47
        $transfer = $this->hyperwalletService->getTransferService()->create($transferDetails);
48
        return $this->render('default/dump-input-id.html.twig', [
49
            'raw_result' => false,
50
            'result' => $transfer,
51
            'result_id' => $transfer->getToken(),
0 ignored issues
show
Bug introduced by
The method getToken() does not exist on Exception. It seems like you code against a sub-type of Exception such as Symfony\Component\Securi...AuthenticationException. ( Ignorable by Annotation )

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

51
            'result_id' => $transfer->/** @scrutinizer ignore-call */ getToken(),
Loading history...
52
        ]);
53
    }
54
55
    /**
56
     * @Route("/search", name="search", methods={"GET"})
57
     *
58
     * @return Response
59
     * @throws HyperwalletApiException
60
     */
61
    public function searchTransfer(): Response
62
    {
63
        $transfers = $this->hyperwalletService->getTransferService()->list();
64
        return $this->render('hyperwallet/transfers/search.html.twig', [
65
            'transfers' => $transfers,
66
        ]);
67
    }
68
69
    /**
70
     * @Route("/{transferToken}", name="get", methods={"GET"})
71
     *
72
     * @param string $transferToken
73
     *
74
     * @return Response
75
     */
76
    public function getTransfer(string $transferToken): Response
77
    {
78
        $transfer = $this->hyperwalletService->getTransferService()->get($transferToken);
79
        return $this->render('default/dump.html.twig', [
80
            'raw_result' => false,
81
            'result' => $transfer,
82
        ]);
83
    }
84
85
    /**
86
     * @Route("/{transferToken}/commit", name="commit", methods={"GET"})
87
     *
88
     * @param string $transferToken
89
     *
90
     * @return Response
91
     */
92
    public function commitTransfer(string $transferToken): Response
93
    {
94
        $transfer = $this->hyperwalletService->getTransferService()->commit($transferToken);
95
        return $this->render('default/dump.html.twig', [
96
            'raw_result' => false,
97
            'result' => $transfer,
98
        ]);
99
    }
100
}
101