2024-05-06 12:52:55 +02:00
|
|
|
<?php
|
|
|
|
namespace feed;
|
|
|
|
|
|
|
|
class Episode {
|
|
|
|
public string $title;
|
|
|
|
public string $pubDate;
|
|
|
|
public string $desc;
|
2024-05-06 18:27:06 +02:00
|
|
|
public string $audioData;
|
2024-05-06 12:52:55 +02:00
|
|
|
|
|
|
|
function __construct($epData) {
|
|
|
|
$this->title = $epData->title;
|
2024-05-06 18:27:06 +02:00
|
|
|
$this->pubDate = $this->formatDate($epData->pubDate);
|
|
|
|
$this->desc = preg_replace("/<br \/>.+<\/p>/", "", $epData->description);
|
|
|
|
$this->audioData = $this->formatAudioData($epData->enclosure->attributes());
|
|
|
|
}
|
|
|
|
|
|
|
|
function formatDate($date) {
|
|
|
|
$fmt = new \IntlDateFormatter("fr_FR", null, null);
|
|
|
|
$fmt->setPattern('d MMMM yyyy HH:mm');
|
|
|
|
$dateTimeCFF = \DateTime::createFromFormat(
|
|
|
|
\DateTime::RFC7231,
|
|
|
|
$date
|
|
|
|
);
|
|
|
|
return $fmt->format($dateTimeCFF);
|
|
|
|
}
|
|
|
|
|
|
|
|
function formatAudioData($rawAudioData) {
|
|
|
|
return "src={$rawAudioData->url}".
|
|
|
|
" type={$rawAudioData->type}".
|
|
|
|
" length={$rawAudioData->length}";
|
2024-05-06 12:52:55 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
function getFormatedAudioData() {
|
2024-05-06 18:27:06 +02:00
|
|
|
return "src={$this->audioData["url"]} length={$this->audioData["length"]} type={$this->audioData["type"]}";
|
2024-05-06 12:52:55 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
?>
|