-
Notifications
You must be signed in to change notification settings - Fork 0
/
Exporter.php
90 lines (79 loc) · 2.96 KB
/
Exporter.php
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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
<?php
declare(strict_types=1);
include('vendor/autoload.php');
use Application\Exporter\Article\Visitor\Factory\ArrayAuthorAggregatedVisitorFactory;
use Application\Exporter\Article\Visitor\Factory\ArrayVisitorFactory;
use Application\Exporter\Article\Visitor\Factory\JsonAuthorAggregatedVisitorFactory;
use Application\Exporter\Article\Visitor\Factory\JsonVisitorFactory;
use Application\Exporter\Exporter;
use Application\Exporter\Model\Article\ExportableDraftArticle;
use Application\Exporter\Model\Article\ExportablePublishedArticle;
use Application\Exporter\Model\Article\ExportableReadyForReviewArticle;
use Application\Exporter\Model\Article\ExportableReviewedArticle;
use Domain\Article\DraftArticle;
use Domain\Article\PublishedArticle;
use Domain\Article\ReadyForReviewArticle;
use Domain\Article\ReviewedArticle;
use Domain\User\User;
$donCallisto = new User('DonCallisto', 'samuele.lilli@gmail.com');
$johnDoe = new User('JohnDoe', 'john.doe@gmail.com');
$otsillacNod = new User('OtsillacNod', 'samuele.lilli@madisoft.it');
$a1 = new ExportableDraftArticle(
new DraftArticle($donCallisto, 'foo')
);
$a2 = new ExportableReadyForReviewArticle(
new ReadyForReviewArticle(
new DraftArticle($donCallisto, 'foo')
)
);
$a3 = new ExportableReviewedArticle(
new ReviewedArticle(
new ReadyForReviewArticle(
new DraftArticle($donCallisto, 'foo'),
),
$otsillacNod
)
);
$a4 = new ExportablePublishedArticle(
new PublishedArticle(
new ReviewedArticle(
new ReadyForReviewArticle(
new DraftArticle($donCallisto, 'foo'),
),
$otsillacNod
),
new \DateTime()
)
);
$a5 = new ExportableDraftArticle(
new DraftArticle($johnDoe, 'foo')
);
$a6 = new ExportableReadyForReviewArticle(
new ReadyForReviewArticle(
new DraftArticle($johnDoe, 'foo')
)
);
echo 'Start array exporting...' . PHP_EOL;
$exporter = new Exporter();
$result = $exporter->export(new ArrayVisitorFactory(), $a1, $a2, $a3, $a4, $a5, $a6);
echo 'Results: ' . PHP_EOL;
echo print_r($result, true) . PHP_EOL;
echo 'Finish array exporting' . PHP_EOL;
echo 'Start json exporting...' . PHP_EOL;
$exporter = new Exporter();
$result = $exporter->export(new JsonVisitorFactory(), $a1, $a2, $a3, $a5, $a6);
echo 'Results: ' . PHP_EOL;
echo print_r($result, true) . PHP_EOL;
echo 'Finish array exporting' . PHP_EOL;
echo 'Start array (author aggregated) exporting...' . PHP_EOL;
$exporter = new Exporter();
$result = $exporter->export(new ArrayAuthorAggregatedVisitorFactory(), $a1, $a2, $a3, $a4, $a5, $a6);
echo 'Results: ' . PHP_EOL;
echo print_r($result, true) . PHP_EOL;
echo 'Finish array exporting' . PHP_EOL;
echo 'Start json (author aggregated) exporting...' . PHP_EOL;
$exporter = new Exporter();
$result = $exporter->export(new JsonAuthorAggregatedVisitorFactory(), $a1, $a2, $a3, $a5, $a6);
echo 'Results: ' . PHP_EOL;
echo print_r($result, true) . PHP_EOL;
echo 'Finish array exporting' . PHP_EOL;