MissingDelegateInformation   A
last analyzed

Complexity

Total Complexity 6

Size/Duplication

Total Lines 40
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
dl 0
loc 40
rs 10
c 0
b 0
f 0
wmc 6

2 Methods

Rating   Name   Duplication   Size   Complexity  
B produceReport() 0 24 5
A __construct() 0 3 1
1
<?php
2
3
namespace ConferenceTools\Tickets\Report;
4
5
use Doctrine\ORM\EntityManagerInterface;
6
use ConferenceTools\Tickets\Domain\ReadModel\TicketRecord\TicketRecord;
7
8
final class MissingDelegateInformation implements ReportInterface
9
{
10
    /**
11
     * @var EntityManagerInterface
12
     */
13
    private $em;
14
15
    /**
16
     * DelegateInformation constructor.
17
     * @param EntityManagerInterface $em
18
     */
19
    public function __construct(EntityManagerInterface $em)
20
    {
21
        $this->em = $em;
22
    }
23
24
    public function produceReport(): array
25
    {
26
        $report = [];
27
        $tickets = $this->em->getRepository(TicketRecord::class)->findAll();
28
        foreach ($tickets as $ticket)
29
        {
30
            /** @var TicketRecord $ticket */
31
            if (
32
                empty($ticket->getDelegate()->getEmail()) &&
33
                empty($ticket->getDelegate()->getFirstname()) &&
34
                empty($ticket->getDelegate()->getLastname())
35
            ) {
36
37
                $item = [
38
                    'purchase_id' => $ticket->getPurchase()->getPurchaseId(),
39
                    'ticket_id' => $ticket->getTicketId(),
40
                    'email' => $ticket->getPurchase()->getPurchaserEmail()
41
                ];
42
43
                $report[] = $item;
44
            }
45
        }
46
47
        return $report;
48
    }
49
}