GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.

ReportController   A
last analyzed

Complexity

Total Complexity 1

Size/Duplication

Total Lines 48
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
eloc 14
c 0
b 0
f 0
dl 0
loc 48
ccs 0
cts 14
cp 0
rs 10
wmc 1

1 Method

Rating   Name   Duplication   Size   Complexity  
A generateReport() 0 20 1
1
<?php
2
3
namespace Awin\ReportTask\Bundle\ReportBundle\Controller\v1;
4
5
use Awin\ReportTask\Bundle\ReportBundle\Model\Merchant;
6
use Awin\ReportTask\Bundle\ReportBundle\Model\TransactionCsvStorage;
7
use Awin\ReportTask\Bundle\ReportBundle\Model\TransactionTable;
8
use Awin\ReportTask\Bundle\ReportBundle\Service\Observer\ReportObserver;
9
use Symfony\Component\HttpFoundation\Request;
10
use Symfony\Component\HttpFoundation\JsonResponse;
11
use FOS\RestBundle\Controller\FOSRestController;
12
use FOS\RestBundle\Controller\Annotations as Rest;
13
use Nelmio\ApiDocBundle\Annotation\ApiDoc;
14
15
class ReportController extends FOSRestController
16
{
17
    /**
18
     * @ApiDoc(
19
     *  resource=false,
20
     *  description="The endpoint to generate merchant report",
21
     *  headers={
22
     *         {
23
     *             "name"="Access-Token",
24
     *             "description"="Domain ID or token"
25
     *         }
26
     *     },
27
     *     statusCodes={
28
     *          200="Returned when report is generated successful",
29
     *          403="Returned when request is not authorised",
30
     *          500={
31
     *           "Returned when the report generation fails",
32
     *           "Returned when input param lead to the validation failure"
33
     *         }
34
     *     },
35
     *     parameters={
36
     *         {"name"="merchant_id", "dataType"="int", "required"=false, "description"="the merchant_id for generate report"},
37
     *         {"name"="date", "dataType"="string", "required"=false, "description"="the date for generate report"}
38
     *     }
39
     *  )
40
     *
41
     * @return JsonResponse
42
     */
43
    public function generateReport(Request $request)
44
    {
45
        $merchantId = $request->get('merchant_id');
46
        $date       = $request->get('date');
47
48
        $reportService              = $this->container->get('app.report_service');
49
        $reportService->attach(new ReportObserver());
50
        $currencyService            = $this->container->get('app.currency_service');
51
        $merchantTransactionService = $this->container->get('app.merchant_transaction_service');
52
        $merchantTransactionService->setTransactionRepository(new TransactionTable('var/storage/data.csv'));
53
        $merchantTransactionService->setMerchantRepository(new Merchant());
54
        $storage                    = new TransactionCsvStorage('var/storage/data.csv');
55
56
        $reportService->generate($merchantTransactionService, $currencyService, $storage, $merchantId, $date);
57
58
        $response = new JsonResponse([
59
            'success' => true,
60
        ]);
61
62
        return $response;
63
    }
64
}