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

MarkPurchasePaid   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 33
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
dl 0
loc 33
rs 10
c 0
b 0
f 0
wmc 3

3 Methods

Rating   Name   Duplication   Size   Complexity  
A configure() 0 7 1
A execute() 0 8 1
A build() 0 6 1
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
}