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.

ReportCommand::configure()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 13
Code Lines 11

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 11
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 11
c 1
b 0
f 0
nc 1
nop 0
dl 0
loc 13
ccs 11
cts 11
cp 1
crap 1
rs 9.9
1
<?php
2
3
namespace Awin\ReportTask\Bundle\ReportBundle\Command;
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\Bundle\FrameworkBundle\Command\ContainerAwareCommand;
10
use Symfony\Component\Console\Input\InputArgument;
11
use Symfony\Component\Console\Input\InputInterface;
12
use Symfony\Component\Console\Input\InputOption;
13
use Symfony\Component\Console\Output\OutputInterface;
14
use Symfony\Component\DependencyInjection\ContainerAwareTrait;
15
16
/**
17
 * The console command to generate the merchant transaction report.
18
 * It can filter by either merchant_id, date or both, the command format is
19
 *
20
 * php bin/console report:merchant                   (generate all the transaction)
21
 * php bin/console report:merchant 1                 (generate the transaction for merchant_id 1)
22
 * php bin/console report:merchant 1 01/05/2010      (generate the transactions for merchant_id 1 and on date 01/05/2010)
23
 * php bin/console report:merchant null 01/05/201    (generate the transactions only on 01/05/2010)
24
 *
25
 * @date       24/06/2017
26
 * @time       10:13
27
 * @author     Peng Yue <[email protected]>
28
 * @copyright  2004-2017 Peng Yue
29
 */
30
31
class ReportCommand extends ContainerAwareCommand
32
{
33
    use ContainerAwareTrait;
34
35
    /**
36
     * Configure the command parameters
37
     */
38 1
    protected function configure()
39
    {
40 1
        $this->setName('report:merchant')
41 1
             ->setDescription('Generate the merchant transactions report')
42 1
            ->addArgument(
43 1
                'merchant_id',
44 1
                InputArgument::OPTIONAL,
45 1
                'Which merchant you would like to generate report for'
46
            )
47 1
            ->addArgument(
48 1
                'date',
49 1
                InputArgument::OPTIONAL,
50 1
                'If null is set, all the transaction will be added in the report, 
51
                otherwise only transaction on that date will be generated'
52
            );
53 1
    }
54
55
    /**
56
     * Pull the services together and run the command
57
     *
58
     * @param InputInterface $input
59
     * @param OutputInterface $output
60
     *
61
     * @return bool
62
     */
63 1
    protected function execute(InputInterface $input, OutputInterface $output)
64
    {
65 1
        $dataFilePath               = 'var/storage/data.csv';
66 1
        $reportFilePath             = 'var/storage/report.csv';
67 1
        $merchantId                 = $input->getArgument('merchant_id');
68 1
        $date                       = $input->getArgument('date');
69
70 1
        $reportService              = $this->getContainer()->get('app.report_service');
71 1
        $currencyService            = $this->getContainer()->get('app.currency_service');
72 1
        $merchantTransactionService = $this->getContainer()->get('app.merchant_transaction_service');
73
74 1
        $reportService->attach(new ReportObserver());
75 1
        $reportService->setReportFilePath($reportFilePath);
76 1
        $merchantTransactionService->setTransactionRepository(new TransactionTable($dataFilePath));
77 1
        $merchantTransactionService->setMerchantRepository(new Merchant());
78 1
        $storage = new TransactionCsvStorage($dataFilePath);
79
80 1
        $reportService->generate($merchantTransactionService, $currencyService, $storage, $merchantId, $date);
81
82 1
        echo sprintf('Csv report file has been generated at %s%s', $reportFilePath, PHP_EOL);
83
    }
84
}