ProcessPaymentsCommand::execute()   A
last analyzed

Complexity

Conditions 3
Paths 3

Size

Total Lines 16
Code Lines 11

Duplication

Lines 16
Ratio 100 %

Importance

Changes 0
Metric Value
dl 16
loc 16
rs 9.4285
c 0
b 0
f 0
cc 3
eloc 11
nc 3
nop 2
1
<?php
2
3
/**
4
 * @author    Markus Tacker <[email protected]>
5
 * @copyright 2013-2016 Verein zur Förderung der Netzkultur im Rhein-Main-Gebiet e.V. | http://netzkultur-rheinmain.de/
6
 */
7
8
namespace BCRM\BackendBundle\Command;
9
10
use BCRM\BackendBundle\Service\Payment\CheckPaymentCommand;
11
use Symfony\Bundle\FrameworkBundle\Command\ContainerAwareCommand;
12
use Symfony\Component\Console\Input\InputInterface;
13
use Symfony\Component\Console\Output\OutputInterface;
14
15
class ProcessPaymentsCommand extends ContainerAwareCommand
16
{
17
    /**
18
     * @var OutputInterface
19
     */
20
    private $output;
21
22
    protected function configure()
23
    {
24
        $this
25
            ->setName('bcrm:payments:process')
26
            ->setDescription('Process new payments');
27
    }
28
29 View Code Duplication
    protected function execute(InputInterface $input, OutputInterface $output)
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...
30
    {
31
        $this->output = $output;
32
        /** @var \BCRM\BackendBundle\Entity\PaymentRepository $paymentRepo */
33
        $paymentRepo = $this->getContainer()->get('bcrm.backend.repo.payment');
34
        $commandBus  = $this->getContainer()->get('command_bus');
35
        foreach ($paymentRepo->getUnchecked() as $payment) {
36
            if ($this->output->getVerbosity() > OutputInterface::VERBOSITY_NORMAL) {
37
                $this->output->writeln(sprintf('Checking payment %s', $payment));
38
            }
39
            $command          = new CheckPaymentCommand();
40
            $command->payment = $payment;
41
            $command->sandbox = $this->getContainer()->getParameter('paypal_sandbox');
42
            $commandBus->handle($command);
43
        }
44
    }
45
}
46