Completed
Push — master ( 93b855...faa581 )
by Cesar
21s queued 10s
created

TransfersController::index()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
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 View Code Duplication
    public function createTransferPost(): Response
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
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(),
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 View Code Duplication
    public function getTransfer(string $transferToken): Response
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
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