DelegateRequirements   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 35
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
dl 0
loc 35
rs 10
c 0
b 0
f 0
wmc 4

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 3 1
A produceReport() 0 19 3
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 DelegateRequirements 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 (!empty($ticket->getDelegate()->getRequirements())) {
32
                $item = [
33
                    'firstname' => $ticket->getDelegate()->getFirstname(),
34
                    'lastname' => $ticket->getDelegate()->getLastname(),
35
                    'requirements' => $ticket->getDelegate()->getRequirements(),
36
                ];
37
38
                $report[] = $item;
39
            }
40
        }
41
42
        return $report;
43
    }
44
}