Passed
Push — master ( df6dd9...6f6e5f )
by Chris
04:08 queued 01:22
created

MarkPurchasePaid::configure()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 7
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 5
nc 1
nop 0
dl 0
loc 7
rs 9.4285
c 0
b 0
f 0
1
<?php
2
3
namespace ConferenceTools\Tickets\Cli\Command;
4
5
use Carnage\Cqrs\MessageBus\MessageBusInterface;
6
use Carnage\Cqrs\Service\EventCatcher;
7
use ConferenceTools\Tickets\Domain\Command\Ticket\CompletePurchase;
8
use ConferenceTools\Tickets\Domain\Command\Ticket\MakePayment;
9
use ConferenceTools\Tickets\Domain\Command\Ticket\ReserveTickets;
10
use ConferenceTools\Tickets\Domain\Event\Ticket\TicketPurchaseCreated;
11
use ConferenceTools\Tickets\Domain\Service\Configuration;
12
use ConferenceTools\Tickets\Domain\ValueObject\Delegate;
13
use ConferenceTools\Tickets\Domain\ValueObject\DiscountCode;
14
use ConferenceTools\Tickets\Domain\ValueObject\TicketReservationRequest;
15
use ConferenceTools\Tickets\Domain\ValueObject\TicketType;
16
use Symfony\Component\Console\Command\Command;
17
use Symfony\Component\Console\Input\InputArgument;
18
use Symfony\Component\Console\Input\InputInterface;
19
use Symfony\Component\Console\Input\InputOption;
20
use Symfony\Component\Console\Output\OutputInterface;
21
22
class MarkPurchasePaid extends Command
23
{
24
    /**
25
     * @var MessageBusInterface
26
     */
27
    private $commandBus;
28
29
    public static function build(MessageBusInterface $commandBus)
30
    {
31
        $instance = new static();
32
        $instance->commandBus = $commandBus;
33
34
        return $instance;
35
    }
36
37
    protected function configure()
38
    {
39
        $this->setName('tickets:mark-purchase-paid')
40
            ->setDescription('Marks a purchase made via the web as paid')
41
            ->setDefinition([
42
                new InputArgument('purchaseId', InputArgument::REQUIRED, 'Id of purchase to mark paid'),
43
                new InputArgument('email', InputArgument::REQUIRED, 'Email address for purchaser'),
44
            ]);
45
    }
46
47
    protected function execute(InputInterface $input, OutputInterface $output)
48
    {
49
        $email = $input->getArgument('email');
50
        $purchaseId = $input->getArgument('purchaseId');
51
52
        $this->commandBus->dispatch(new MakePayment($purchaseId, $email));
53
54
        $output->writeln(sprintf('Marked paid. PurchaseId: %s', $purchaseId));
55
    }
56
}