Completed
Push — master ( 7c1eaa...80d841 )
by Joachim
15:53
created

TestController   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 43
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 5

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
A indexAction() 0 14 1
A checksum1Action() 0 6 1
1
<?php
2
3
namespace Loevgaard\DandomainAltapayBundle\Controller;
4
5
use Loevgaard\Dandomain\Pay\Handler;
6
use Loevgaard\Dandomain\Pay\PaymentRequest;
7
use Loevgaard\DandomainAltapayBundle\Entity\TerminalInterface;
8
use Loevgaard\DandomainAltapayBundle\Form\TestType;
9
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Method;
10
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
11
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
12
use Symfony\Component\HttpFoundation\JsonResponse;
13
use Symfony\Component\HttpFoundation\Request;
14
use Symfony\Component\HttpFoundation\Response;
15
16
/**
17
 * @Route("/test")
18
 */
19
class TestController extends Controller
20
{
21
    /**
22
     * @Method("GET")
23
     * @Route("", name="loevgaard_dandomain_altapay_test_index")
24
     *
25
     * @param Request $request
26
     *
27
     * @return Response
28
     */
29
    public function indexAction(Request $request)
0 ignored issues
show
Unused Code introduced by
The parameter $request is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
30
    {
31
        /** @var TerminalInterface[] $terminals */
32
        $terminals = $this->get('loevgaard_dandomain_altapay.terminal_manager')->getRepository()->findAll();
33
34
        $form = $this->createForm(TestType::class);
35
36
        return $this->render('@LoevgaardDandomainAltapay/test/index.html.twig', [
37
            'form' => $form->createView(),
38
            'shared_key_1' => $this->getParameter('loevgaard_dandomain_altapay.shared_key_1'),
39
            'shared_key_2' => $this->getParameter('loevgaard_dandomain_altapay.shared_key_2'),
40
            'terminals' => $terminals,
41
        ]);
42
    }
43
44
    /**
45
     * @Method("GET")
46
     * @Route("/checksum1/{orderId}/{amount}/{sharedKey}/{currency}", name="loevgaard_dandomain_altapay_test_checksum_1")
47
     *
48
     * @param int    $orderId
49
     * @param string $amount
50
     * @param string $sharedKey
51
     * @param int    $currency
52
     *
53
     * @return JsonResponse
54
     */
55
    public function checksum1Action($orderId, $amount, $sharedKey, $currency)
56
    {
57
        $amount = PaymentRequest::currencyStringToFloat($amount);
58
59
        return new JsonResponse(Handler::generateChecksum1((int) $orderId, $amount, $sharedKey, (int) $currency));
60
    }
61
}
62