Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
Total | |
0.00% |
0 / 26 |
|
0.00% |
0 / 1 |
CRAP | |
0.00% |
0 / 1 |
OlzEventData | |
0.00% |
0 / 26 |
|
0.00% |
0 / 1 |
6 | |
0.00% |
0 / 1 |
getHtml | |
0.00% |
0 / 26 |
|
0.00% |
0 / 1 |
6 |
1 | <?php |
2 | |
3 | // ============================================================================= |
4 | // Strukturierte Daten (siehe https://schema.org) zur OL Zimmerberg. |
5 | // ============================================================================= |
6 | |
7 | namespace Olz\Components\Schema\OlzEventData; |
8 | |
9 | use Olz\Components\Common\OlzComponent; |
10 | |
11 | /** @extends OlzComponent<array<string, mixed>> */ |
12 | class OlzEventData extends OlzComponent { |
13 | public function getHtml(mixed $args): string { |
14 | $name = $args['name'] ?? ''; |
15 | $start_date = $args['start_date'] ?? null; |
16 | $end_date = $args['end_date'] ?? null; |
17 | $location = $args['location'] ?? null; |
18 | $place = $location ? [ |
19 | '@type' => 'Place', |
20 | 'latitude' => $location['lat'], |
21 | 'longitude' => $location['lng'], |
22 | 'name' => $location['name'] ?? null, |
23 | 'address' => 'Unbekannt', |
24 | ] : 'Unbekannt'; |
25 | $event_data = [ |
26 | '@context' => 'https://schema.org', |
27 | '@type' => 'Event', |
28 | 'name' => $name, |
29 | 'startDate' => $start_date, |
30 | 'endDate' => $end_date, |
31 | 'location' => $place, |
32 | 'eventAttendanceMode' => 'OfflineEventAttendanceMode', |
33 | 'eventStatus' => 'EventScheduled', |
34 | ]; |
35 | $json_event_data = json_encode($event_data); |
36 | return <<<ZZZZZZZZZZ |
37 | <script type="application/ld+json"> |
38 | {$json_event_data} |
39 | </script> |
40 | ZZZZZZZZZZ; |
41 | } |
42 | } |