site-web-le-plus-beau-des-v.../tools/episode.php

37 lines
1.1 KiB
PHP
Raw Permalink Normal View History

<?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;
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}";
}
function getFormatedAudioData() {
2024-05-06 18:27:06 +02:00
return "src={$this->audioData["url"]} length={$this->audioData["length"]} type={$this->audioData["type"]}";
}
}
?>