-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathindex.php
More file actions
41 lines (36 loc) · 1.05 KB
/
index.php
File metadata and controls
41 lines (36 loc) · 1.05 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
<?php
declare(strict_types=1);
use App\Collection\LecturerCollection;
use App\Entity\Lecturer;
use App\Exception\InvalidFirstnameException;
use App\Exception\InvalidSurnameException;
use App\ValueObject\Surname;
require __DIR__.'/vendor/autoload.php';
$lecturers = [];
try {
$lecturers = [
new Lecturer(new Surname('Cumming'), 'Andrew', 'c49', '2753'),
new Lecturer(new Surname('Cumming'), 'Andrew', 'c49', '2753'),
];
} catch(InvalidFirstnameException $exception) {
echo "Cas 1 : {$exception->getMessage()}\n";
} catch(InvalidSurnameException $exception) {
echo "Cas 2 : {$exception->getMessage()}\n";
}
$lecturers = new LecturerCollection(...$lecturers);
?>
<table>
<tr>
<th>Name</th>
<th>Office</th>
<th>Phone</th>
</tr>
<?php var_dump($lecturers) ?>
<?php foreach ($lecturers as $lecturer): /* @var $lecturer Lecturer */ ?>
<tr>
<td><?php echo $lecturer->getName(); ?></td>
<td><?php echo $lecturer->getOffice(); ?></td>
<td><?php echo $lecturer->getPhone(); ?></td>
</tr>
<?php endforeach; ?>
</table>