Readd gpodder stubs

This commit is contained in:
Michel Roux 2023-08-02 12:13:16 +02:00
parent 68c6f8234e
commit df30ff2318
14 changed files with 274 additions and 0 deletions

View File

@ -15,6 +15,12 @@
"psalm:check": "psalm.phar --threads=1 --no-cache --show-info=true",
"psalm:fix": "psalm.phar --no-cache --alter --issues=InvalidReturnType,InvalidNullableReturnType,MissingParamType,InvalidFalsableReturnType"
},
"autoload": {
"psr-4": {
"OCA\\RePod\\": "lib/",
"OCA\\GPodderSync\\": "stubs/OCA/GPodderSync/"
}
},
"config": {
"platform": {
"php": "8.0"

View File

@ -10,6 +10,7 @@
>
<projectFiles>
<directory name="lib" />
<directory name="stubs" />
<ignoreFiles>
<directory name="vendor" />
</ignoreFiles>

View File

@ -0,0 +1,44 @@
<?php
declare(strict_types=1);
namespace OCA\GPodderSync\Core\EpisodeAction;
/**
* @psalm-type EpisodeActionType = array{
* podcast: string,
* episode: string,
* action: string,
* timestamp: string,
* started: int,
* position: int,
* total: int,
* guid: ?string,
* id: int
* }
*/
interface EpisodeAction
{
public function getPodcast(): string;
public function getEpisode(): string;
public function getAction(): string;
public function getTimestamp(): string;
public function getStarted(): int;
public function getPosition(): int;
public function getTotal(): int;
public function getGuid(): ?string;
public function getId(): int;
/**
* @return EpisodeActionType
*/
public function toArray(): array;
}

View File

@ -0,0 +1,15 @@
<?php
declare(strict_types=1);
namespace OCA\GPodderSync\Core\EpisodeAction;
interface EpisodeActionReader
{
/**
* @param array $episodeActionsArray []
* @return EpisodeAction[]
* @throws \InvalidArgumentException
*/
public function fromArray(array $episodeActionsArray): array;
}

View File

@ -0,0 +1,10 @@
<?php
declare(strict_types=1);
namespace OCA\GPodderSync\Core\EpisodeAction;
interface EpisodeActionSaver
{
public function saveEpisodeActions(array $episodeActionsArray, string $userId): array;
}

View File

@ -0,0 +1,29 @@
<?php
declare(strict_types=1);
namespace OCA\GPodderSync\Core\PodcastData;
/**
* @psalm-type PodcastActionCountsType = array{
* delete: int,
* download: int,
* flattr: int,
* new: int,
* play: int
* }
*/
interface PodcastActionCounts extends \JsonSerializable
{
public function incrementAction(string $action): void;
/**
* @return PodcastActionCountsType
*/
public function toArray(): array;
/**
* @return PodcastActionCountsType
*/
public function jsonSerialize(): array;
}

View File

@ -0,0 +1,57 @@
<?php
declare(strict_types=1);
namespace OCA\GPodderSync\Core\PodcastData;
/**
* @psalm-type PodcastDataType = array{
* title: ?string,
* author: ?string,
* link: ?string,
* description: ?string,
* imageUrl: ?string,
* fetchedAtUnix: int,
* imageBlob: ?string
* }
*/
interface PodcastData extends \JsonSerializable
{
public function __toString(): string;
/**
* @throws \Exception if the XML data could not be parsed
*/
public static function parseRssXml(string $xmlString, ?int $fetchedAtUnix = null): PodcastData;
public function getTitle(): ?string;
public function getAuthor(): ?string;
public function getLink(): ?string;
public function getDescription(): ?string;
public function getImageUrl(): ?string;
public function getFetchedAtUnix(): ?int;
public function getImageBlob(): ?string;
public function setImageBlob(?string $blob): void;
/**
* @return PodcastDataType
*/
public function toArray(): array;
/**
* @return PodcastDataType
*/
public function jsonSerialize(): array;
/**
* @param PodcastDataType $data
*/
public static function fromArray(array $data): PodcastData;
}

View File

@ -0,0 +1,16 @@
<?php
declare(strict_types=1);
namespace OCA\GPodderSync\Core\PodcastData;
interface PodcastDataReader
{
public function getCachedOrFetchPodcastData(string $url, string $userId): ?PodcastData;
public function fetchPodcastData(string $url, string $userId): ?PodcastData;
public function tryGetCachedPodcastData(string $url): ?PodcastData;
public function trySetCachedPodcastData(string $url, PodcastData $data): bool;
}

View File

@ -0,0 +1,33 @@
<?php
declare(strict_types=1);
namespace OCA\GPodderSync\Core\PodcastData;
/**
* @psalm-type PodcastMetricsType = array{
* url: string,
* listenedSeconds: int,
* actionCounts: PodcastActionCounts
* }
*/
interface PodcastMetrics extends \JsonSerializable
{
public function getUrl(): string;
public function getActionCounts(): PodcastActionCounts;
public function getListenedSeconds(): int;
public function addListenedSeconds(int $seconds): void;
/**
* @return PodcastMetricsType
*/
public function toArray(): array;
/**
* @return PodcastMetricsType
*/
public function jsonSerialize(): array;
}

View File

@ -0,0 +1,13 @@
<?php
declare(strict_types=1);
namespace OCA\GPodderSync\Core\PodcastData;
interface PodcastMetricsReader
{
/**
* @return PodcastMetrics[]
*/
public function metrics(string $userId): array;
}

View File

@ -0,0 +1,14 @@
<?php
declare(strict_types=1);
namespace OCA\GPodderSync\Core\SubscriptionChange;
interface SubscriptionChange
{
public function __toString(): string;
public function isSubscribed(): bool;
public function getUrl(): string;
}

View File

@ -0,0 +1,13 @@
<?php
declare(strict_types=1);
namespace OCA\GPodderSync\Core\SubscriptionChange;
interface SubscriptionChangeRequestParser
{
/**
* @return SubscriptionChange[]
*/
public function createSubscriptionChangeList(array $urlsSubscribed, array $urlsUnsubscribed): array;
}

View File

@ -0,0 +1,10 @@
<?php
declare(strict_types=1);
namespace OCA\GPodderSync\Core\SubscriptionChange;
interface SubscriptionChangeSaver
{
public function saveSubscriptionChanges(array $urlsSubscribed, array $urlsUnsubscribed, string $userId): void;
}

View File

@ -0,0 +1,13 @@
<?php
declare(strict_types=1);
namespace OCA\GPodderSync\Core\SubscriptionChange;
interface SubscriptionChangesReader
{
/**
* @return SubscriptionChange[]
*/
public static function mapToSubscriptionsChanges(array $urls, bool $subscribed): array;
}