Completed
Pull Request — master (#17)
by Cesar
10:49
created

BillingAgreementsController::tokenCreate()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 9

Duplication

Lines 9
Ratio 100 %

Importance

Changes 0
Metric Value
dl 9
loc 9
rs 9.9666
c 0
b 0
f 0
cc 1
nc 1
nop 0
1
<?php
2
3
namespace App\Controller\Paypal;
4
5
use Symfony\Component\HttpFoundation\JsonResponse;
6
use Symfony\Component\HttpFoundation\Request;
7
use Symfony\Component\HttpFoundation\Response;
8
use Symfony\Component\Routing\Annotation\Route;
9
10
/**
11
 * Class BillingAgreementsController
12
 * @package App\Controller\Paypal
13
 * @Route("/paypal/billing-agreements", name="paypal-billing-agreements-")
14
 */
15
class BillingAgreementsController extends AbstractController
16
{
17
    /**
18
     * @Route("/", name="index", methods={"GET"})
19
     * @return Response
20
     */
21
    public function index()
22
    {
23
        return $this->render('paypal/billingAgreements/base.html.twig');
24
    }
25
26
    /**
27
     * @Route("/token", name="token-create", methods={"POST"})
28
     * @return JsonResponse
29
     */
30 View Code Duplication
    public function tokenCreate()
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...
31
    {
32
        $request = Request::createFromGlobals();
33
        $requestBody = $request->getContent();
34
        $response = $this->paypalService->getBillingAgreementService()->createBillingAgreementToken($requestBody);
35
        return new JsonResponse(
36
            $response['result']
37
        );
38
    }
39
40
    /**
41
     * @Route("/", name="create", methods={"POST"})
42
     * @return JsonResponse
43
     */
44 View Code Duplication
    public function billingAgreementCreate()
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...
45
    {
46
        $request = Request::createFromGlobals();
47
        $requestBody = $request->getContent();
48
        $response = $this->paypalService->getBillingAgreementService()->createBillingAgreement($requestBody);
49
        return new JsonResponse(
50
            $response['result']
51
        );
52
    }
53
54
    /**
55
     * @Route("/{billingAgreementId}", name="delete", methods={"DELETE"})
56
     * @param string $billingAgreementId
57
     * @return JsonResponse
58
     */
59
    public function billingAgreementDelete(string $billingAgreementId)
60
    {
61
        $response = $this->paypalService->getBillingAgreementService()->deleteBillingAgreement($billingAgreementId);
62
        return new JsonResponse(
63
            $response['result']
64
        );
65
    }
66
67
    /**
68
     * @Route("/reference-trasaction", name="reference-transaction", methods={"POST"})
69
     * @return JsonResponse
70
     */
71 View Code Duplication
    public function referenceTransaction()
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...
72
    {
73
        $request = Request::createFromGlobals();
74
        $requestBody = $request->getContent();
75
        $response = $this->paypalService->getBillingAgreementService()->createReferenceTransaction($requestBody);
76
        return new JsonResponse(
77
            $response['result']
78
        );
79
    }
80
}
81