MissingDelegateInformation::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 1
dl 0
loc 3
rs 10
c 0
b 0
f 0
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
}