-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdesafio-live_coding.php
More file actions
45 lines (36 loc) · 1.14 KB
/
desafio-live_coding.php
File metadata and controls
45 lines (36 loc) · 1.14 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
<?php
Interface Report {
public function generate(string $title, string $content);
}
class XmlReportGenerator implements Report {
public function generate(string $title, string $content)
{
return 'xml/content';
}
}
class PdfReportGenerator implements Report {
public function generate(string $title, string $content)
{
return 'pdf/content';
}
}
class ReportService {
private Report $xmlReport;
private Report $pdfReport;
public function __construct()
{
$this->xmlReport = new XmlReport();
$this->pdfReport = new PdfReport();
}
public function generateXMLReport(string $title, string $content)
{
return $this->xmlReport->generate(string $title, string $content);
}
public function generatePDFReport(string $title, string $content)
{
return $this->pdfReport->generate(string $title, string $content);
}
}
$reportService = new ReportService();
$reportService->generateXMLReport(new XmlReportGenerator('XML Report', 'XML Report Content'));
$reportService->generatePDFReport(new PdfReportGenerator('PDF Report', 'PDF Report Content'));