DelegateInformation::produceReport()   A
last analyzed

Complexity

Conditions 3
Paths 3

Size

Total Lines 23
Code Lines 13

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 3
eloc 13
nc 3
nop 0
dl 0
loc 23
rs 9.0856
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 DelegateInformation 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
            $item = [
32
                'firstname' => $ticket->getDelegate()->getFirstname(),
33
                'lastname' => $ticket->getDelegate()->getLastname(),
34
                'company' => $ticket->getDelegate()->getCompany(),
35
                'twitter' => $ticket->getDelegate()->getTwitter(),
36
                'type' => $ticket->getTicketType()->getDisplayName(),
37
            ];
38
39
            foreach ($ticket->getDelegate()->getAdditionalInformation()->getQuestions() as $question) {
40
                $item[$question->getHandle()] = $question->getHandle();
41
            }
42
43
            $report[] = $item;
44
        }
45
46
        return $report;
47
    }
48
}