SendPayRegistrationMailCommand::execute()   A
last analyzed

Complexity

Conditions 3
Paths 3

Size

Total Lines 16
Code Lines 10

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 10
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\Event\SendPaymentNotificationMailCommand;
11
use Symfony\Bundle\FrameworkBundle\Command\ContainerAwareCommand;
12
use Symfony\Component\Console\Input\InputInterface;
13
use Symfony\Component\Console\Output\OutputInterface;
14
15 View Code Duplication
class SendPayRegistrationMailCommand extends ContainerAwareCommand
0 ignored issues
show
Duplication introduced by
This class 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...
16
{
17
    protected function configure()
18
    {
19
        $this
20
            ->setName('bcrm:registration:pay')
21
            ->setDescription('Send registration payment emails');
22
    }
23
24
    protected function execute(InputInterface $input, OutputInterface $output)
25
    {
26
        /** @var \BCRM\BackendBundle\Entity\Event\RegistrationRepository $repo */
27
        $repo = $this->getContainer()->get('bcrm.backend.repo.registration');
28
        /** @var \LiteCQRS\Bus\CommandBus $commandBus */
29
        $commandBus = $this->getContainer()->get('command_bus');
30
        foreach ($repo->getToPay() as $registration) {
31
            if ($output->getVerbosity() > OutputInterface::VERBOSITY_NORMAL) {
32
                $output->writeln(sprintf('Sending payment notification mail for %s', $registration));
33
            }
34
            $command                = new SendPaymentNotificationMailCommand();
35
            $command->registration  = $registration;
36
            $command->schemeAndHost = $this->getContainer()->getParameter('scheme_and_host');
37
            $commandBus->handle($command);
38
        }
39
    }
40
}
41