nextcloud-gpodder/lib/Core/EpisodeAction/EpisodeActionReader.php
Jonathan Flueren d131b59348 Align episode upload format to gpodder-api
'started', 'position' and 'total' are optional and 'timestamp' is in 'Y-m-d\TH:i:s' format
2021-10-06 19:40:52 +02:00

33 lines
685 B
PHP

<?php
declare(strict_types=1);
namespace OCA\GPodderSync\Core\EpisodeAction;
class EpisodeActionReader
{
/**
* @param $episodeActionsArray[]
* @return EpisodeAction[]
*/
public function fromArray(array $episodeActionsArray): array
{
$episodeActions = [];
foreach($episodeActionsArray as $episodeAction) {
$episodeActions[] = new EpisodeAction(
$episodeAction["podcast"],
$episodeAction["episode"],
$episodeAction["action"],
$episodeAction["timestamp"],
$episodeAction["started"] ?? -1,
$episodeAction["position"] ?? -1,
$episodeAction["total"] ?? -1,
$episodeAction["guid"] ?? null,
null
);
}
return $episodeActions;
}
}