cs fix
Some checks failed
repod / nextcloud (push) Successful in 56s
repod / xml (push) Successful in 13s
repod / nodejs (push) Failing after 1m50s

This commit is contained in:
Michel Roux 2023-12-23 16:25:20 +00:00
parent 4d6f0061a6
commit 93e4998394
31 changed files with 116 additions and 305 deletions

View File

@ -19,13 +19,11 @@ class Application extends App implements IBootstrap
private const GPODDERSYNC_ID = 'gpoddersync';
private const GPODDERSYNC_MIN_VERSION = '3.8.1';
public function __construct()
{
public function __construct() {
parent::__construct(self::APP_ID);
}
public function boot(IBootContext $context): void
{
public function boot(IBootContext $context): void {
/** @psalm-suppress DeprecatedInterface */
$appContainer = $context->getAppContainer();
@ -44,12 +42,9 @@ class Application extends App implements IBootstrap
Util::connectHook('\OCP\Config', 'js', $this, 'extendJsConfig');
}
public function register(IRegistrationContext $context): void
{
}
public function register(IRegistrationContext $context): void {}
public static function extendJsConfig(array $settings): void
{
public static function extendJsConfig(array $settings): void {
/** @var IAppManager $appManager */
$appManager = Server::get(IAppManager::class);

View File

@ -22,16 +22,14 @@ class EpisodesController extends Controller
parent::__construct(Application::APP_ID, $request);
}
public function list(string $url): JSONResponse
{
public function list(string $url): JSONResponse {
$client = $this->clientService->newClient();
$feed = $client->get($url);
return new JSONResponse($this->episodeActionReader->parseRssXml((string) $feed->getBody()), $feed->getStatusCode());
}
public function action(string $url): JSONResponse
{
public function action(string $url): JSONResponse {
$action = $this->episodeActionReader->findByEpisodeUrl($url);
if ($action) {

View File

@ -14,8 +14,7 @@ use OCP\Util;
class PageController extends Controller
{
public function __construct(IRequest $request, private IConfig $config)
{
public function __construct(IRequest $request, private IConfig $config) {
parent::__construct(Application::APP_ID, $request);
}
@ -23,8 +22,7 @@ class PageController extends Controller
* @NoAdminRequired
* @NoCSRFRequired
*/
public function index(): TemplateResponse
{
public function index(): TemplateResponse {
Util::addScript(Application::APP_ID, 'repod-main');
$csp = new ContentSecurityPolicy();

View File

@ -24,8 +24,7 @@ class PodcastController extends Controller
parent::__construct(Application::APP_ID, $request);
}
public function index(string $url): JSONResponse
{
public function index(string $url): JSONResponse {
$podcast = $this->podcastDataReader->tryGetCachedPodcastData($url);
if ($podcast) {

View File

@ -24,8 +24,7 @@ class SearchController extends Controller
parent::__construct(Application::APP_ID, $request);
}
public function index(string $value): JSONResponse
{
public function index(string $value): JSONResponse {
$podcasts = [];
$providers = [$this->fyydService, $this->itunesService];

View File

@ -24,8 +24,7 @@ class ToplistController extends Controller
* @NoAdminRequired
* @NoCSRFRequired
*/
public function index(): JSONResponse
{
public function index(): JSONResponse {
try {
return new JSONResponse($this->fyydService->hot());
} catch (\Exception $e) {

View File

@ -56,46 +56,38 @@ class EpisodeActionExtraData implements \JsonSerializable
$this->episodeAction = $episodeAction;
}
public function __toString(): string
{
public function __toString(): string {
return $this->episodeUrl ?? '/no episodeUrl/';
}
public function getEpisodeGuid(): string
{
public function getEpisodeGuid(): string {
return $this->episodeGuid;
}
public function getEpisodePubDate(): ?\DateTime
{
public function getEpisodePubDate(): ?\DateTime {
return $this->episodePubDate;
}
public function getEpisodeFilesize(): ?int
{
public function getEpisodeFilesize(): ?int {
return $this->episodeFilesize;
}
public function getEpisodeDuration(): ?int
{
public function getEpisodeDuration(): ?int {
return $this->episodeDuration;
}
public function getEpisodeAction(): ?EpisodeAction
{
public function getEpisodeAction(): ?EpisodeAction {
return $this->episodeAction;
}
public function getEpisodeUrl(): ?string
{
public function getEpisodeUrl(): ?string {
return $this->episodeUrl;
}
/**
* @return EpisodeActionExtraDataType
*/
public function toArray(): array
{
public function toArray(): array {
return
[
'podcastName' => $this->podcastName,
@ -116,33 +108,27 @@ class EpisodeActionExtraData implements \JsonSerializable
/**
* @return EpisodeActionExtraDataType
*/
public function jsonSerialize(): mixed
{
public function jsonSerialize(): mixed {
return $this->toArray();
}
public function getPodcastName(): ?string
{
public function getPodcastName(): ?string {
return $this->podcastName;
}
public function getEpisodeName(): ?string
{
public function getEpisodeName(): ?string {
return $this->episodeName;
}
public function getEpisodeLink(): ?string
{
public function getEpisodeLink(): ?string {
return $this->episodeLink;
}
public function getFetchedAtUnix(): int
{
public function getFetchedAtUnix(): int {
return $this->fetchedAtUnix;
}
public function getEpisodeImage(): ?string
{
public function getEpisodeImage(): ?string {
return $this->episodeImage;
}
}

View File

@ -13,11 +13,9 @@ class EpisodeActionReader
public function __construct(
private EpisodeActionRepository $episodeActionRepository,
private UserService $userService
) {
}
) {}
public function findByEpisodeUrl(string $episodeUrl): ?EpisodeAction
{
public function findByEpisodeUrl(string $episodeUrl): ?EpisodeAction {
return $this->episodeActionRepository->findByEpisodeUrl($episodeUrl, $this->userService->getUserUID());
}
@ -26,8 +24,7 @@ class EpisodeActionReader
*
* @throws \Exception if the XML data could not be parsed
*/
public function parseRssXml(string $xmlString, ?int $fetchedAtUnix = null): array
{
public function parseRssXml(string $xmlString, ?int $fetchedAtUnix = null): array {
$episodes = [];
$xml = new \SimpleXMLElement($xmlString);
$channel = $xml->channel;
@ -129,8 +126,7 @@ class EpisodeActionReader
/**
* @param null|\SimpleXMLElement|string $value
*/
private function stringOrNull($value): ?string
{
private function stringOrNull($value): ?string {
if ($value) {
return (string) $value;
}

View File

@ -20,11 +20,9 @@ class FyydService implements IProvider
private IFactory $l10n,
private IUserSession $userSession,
private LoggerInterface $logger
) {
}
) {}
public function search(string $value): array
{
public function search(string $value): array {
$podcasts = [];
$client = $this->clientService->newClient();
@ -57,8 +55,7 @@ class FyydService implements IProvider
/**
* @return PodcastData[]
*/
public function hot(int $count = 10): array
{
public function hot(int $count = 10): array {
$podcasts = [];
$language = 'en';
$userLang = $this->userService->getLangCode();

View File

@ -14,11 +14,9 @@ class ItunesService implements IProvider
public function __construct(
private IClientService $clientService,
private UserService $userService
) {
}
) {}
public function search(string $value): array
{
public function search(string $value): array {
$podcasts = [];
$client = $this->clientService->newClient();

View File

@ -12,30 +12,25 @@ class UserService
public function __construct(
private IFactory $l10n,
private IUserSession $userSession
) {
}
) {}
public function getUserUID(): string
{
public function getUserUID(): string {
$user = $this->userSession->getUser();
return $user ? $user->getUID() : '';
}
public function getIsoCode(): string
{
public function getIsoCode(): string {
return $this->l10n->getUserLanguage($this->userSession->getUser());
}
public function getCountryCode(): string
{
public function getCountryCode(): string {
$isoCodes = explode('_', $this->getIsoCode());
return isset($isoCodes[1]) ? $isoCodes[1] : 'us';
}
public function getLangCode(): string
{
public function getLangCode(): string {
$isoCodes = explode('_', $this->getIsoCode());
return $isoCodes[0];

View File

@ -29,76 +29,55 @@ class EpisodeAction
private int $total,
private ?string $guid,
private ?int $id
) {
}
) {}
/**
* @return string
*/
public function getPodcast()
{
}
public function getPodcast() {}
/**
* @return string
*/
public function getEpisode()
{
}
public function getEpisode() {}
/**
* @return string
*/
public function getAction()
{
}
public function getAction() {}
/**
* @return string
*/
public function getTimestamp()
{
}
public function getTimestamp() {}
/**
* @return int
*/
public function getStarted()
{
}
public function getStarted() {}
/**
* @return int
*/
public function getPosition()
{
}
public function getPosition() {}
/**
* @return int
*/
public function getTotal()
{
}
public function getTotal() {}
/**
* @return ?string
*/
public function getGuid()
{
}
public function getGuid() {}
/**
* @return int
*/
public function getId()
{
}
public function getId() {}
/**
* @return EpisodeActionType
*/
public function toArray()
{
}
public function toArray() {}
}

View File

@ -11,7 +11,5 @@ class EpisodeActionReader
* @return EpisodeAction[]
* @throws \InvalidArgumentException
*/
public function fromArray(array $episodeActionsArray)
{
}
public function fromArray(array $episodeActionsArray) {}
}

View File

@ -13,13 +13,10 @@ class EpisodeActionSaver
private EpisodeActionRepository $episodeActionRepository,
private EpisodeActionWriter $episodeActionWriter,
private EpisodeActionReader $episodeActionReader
) {
}
) {}
/**
* @return array
*/
public function saveEpisodeActions(array $episodeActionsArray, string $userId)
{
}
public function saveEpisodeActions(array $episodeActionsArray, string $userId) {}
}

View File

@ -15,21 +15,15 @@ namespace OCA\GPodderSync\Core\PodcastData;
*/
class PodcastActionCounts implements \JsonSerializable
{
public function incrementAction(string $action): void
{
}
public function incrementAction(string $action): void {}
/**
* @return PodcastActionCountsType
*/
public function toArray()
{
}
public function toArray() {}
/**
* @return PodcastActionCountsType
*/
public function jsonSerialize(): mixed
{
}
public function jsonSerialize(): mixed {}
}

View File

@ -25,89 +25,64 @@ class PodcastData implements \JsonSerializable
private ?string $imageUrl,
private int $fetchedAtUnix,
private ?string $imageBlob = null
) {
}
) {}
/**
* @return PodcastData
* @throws \Exception if the XML data could not be parsed
*/
public static function parseRssXml(string $xmlString, ?int $fetchedAtUnix = null)
{
}
public static function parseRssXml(string $xmlString, ?int $fetchedAtUnix = null) {}
/**
* @return ?string
*/
public function getTitle()
{
}
public function getTitle() {}
/**
* @return ?string
*/
public function getAuthor()
{
}
public function getAuthor() {}
/**
* @return ?string
*/
public function getLink()
{
}
public function getLink() {}
/**
* @return ?string
*/
public function getDescription()
{
}
public function getDescription() {}
/**
* @return ?string
*/
public function getImageUrl()
{
}
public function getImageUrl() {}
/**
* @return ?int
*/
public function getFetchedAtUnix()
{
}
public function getFetchedAtUnix() {}
/**
* @return ?string
*/
public function getImageBlob()
{
}
public function getImageBlob() {}
public function setImageBlob(?string $blob): void
{
}
public function setImageBlob(?string $blob): void {}
/**
* @return PodcastDataType
*/
public function toArray()
{
}
public function toArray() {}
/**
* @return PodcastDataType
*/
public function jsonSerialize(): mixed
{
}
public function jsonSerialize(): mixed {}
/**
* @param PodcastDataType $data
* @return PodcastData
*/
public static function fromArray(array $data)
{
}
public static function fromArray(array $data) {}
}

View File

@ -9,28 +9,20 @@ class PodcastDataReader
/**
* @return ?PodcastData
*/
public function getCachedOrFetchPodcastData(string $url, string $userId)
{
}
public function getCachedOrFetchPodcastData(string $url, string $userId) {}
/**
* @return ?PodcastData
*/
public function fetchPodcastData(string $url, string $userId)
{
}
public function fetchPodcastData(string $url, string $userId) {}
/**
* @return ?PodcastData
*/
public function tryGetCachedPodcastData(string $url)
{
}
public function tryGetCachedPodcastData(string $url) {}
/**
* @return bool
*/
public function trySetCachedPodcastData(string $url, PodcastData $data)
{
}
public function trySetCachedPodcastData(string $url, PodcastData $data) {}
}

View File

@ -17,45 +17,32 @@ class PodcastMetrics implements \JsonSerializable
private string $url,
private int $listenedSeconds = 0,
private ?PodcastActionCounts $actionCounts = null
) {
}
) {}
/**
* @return string
*/
public function getUrl()
{
}
public function getUrl() {}
/**
* @return PodcastActionCounts
*/
public function getActionCounts()
{
}
public function getActionCounts() {}
/**
* @return int
*/
public function getListenedSeconds()
{
}
public function getListenedSeconds() {}
public function addListenedSeconds(int $seconds): void
{
}
public function addListenedSeconds(int $seconds): void {}
/**
* @return PodcastMetricsType
*/
public function toArray()
{
}
public function toArray() {}
/**
* @return PodcastMetricsType
*/
public function jsonSerialize(): mixed
{
}
public function jsonSerialize(): mixed {}
}

View File

@ -9,7 +9,5 @@ class PodcastMetricsReader
/**
* @return PodcastMetrics[]
*/
public function metrics(string $userId)
{
}
public function metrics(string $userId) {}
}

View File

@ -9,20 +9,15 @@ class SubscriptionChange
public function __construct(
private string $url,
private bool $isSubscribed
) {
}
) {}
/**
* @return bool
*/
public function isSubscribed()
{
}
public function isSubscribed() {}
/**
* @return string
*/
public function getUrl()
{
}
public function getUrl() {}
}

View File

@ -6,14 +6,10 @@ namespace OCA\GPodderSync\Core\SubscriptionChange;
class SubscriptionChangeRequestParser
{
public function __construct(private SubscriptionChangesReader $subscriptionChangeReader)
{
}
public function __construct(private SubscriptionChangesReader $subscriptionChangeReader) {}
/**
* @return SubscriptionChange[]
*/
public function createSubscriptionChangeList(array $urlsSubscribed, array $urlsUnsubscribed)
{
}
public function createSubscriptionChangeList(array $urlsSubscribed, array $urlsUnsubscribed) {}
}

View File

@ -6,7 +6,5 @@ namespace OCA\GPodderSync\Core\SubscriptionChange;
class SubscriptionChangeSaver
{
public function saveSubscriptionChanges(array $urlsSubscribed, array $urlsUnsubscribed, string $userId): void
{
}
public function saveSubscriptionChanges(array $urlsSubscribed, array $urlsUnsubscribed, string $userId): void {}
}

View File

@ -9,7 +9,5 @@ class SubscriptionChangesReader
/**
* @return SubscriptionChange[]
*/
public static function mapToSubscriptionsChanges(array $urls, bool $subscribed)
{
}
public static function mapToSubscriptionsChanges(array $urls, bool $subscribed) {}
}

View File

@ -34,7 +34,5 @@ class EpisodeActionEntity extends Entity implements \JsonSerializable
/**
* @return EpisodeActionType[]
*/
public function jsonSerialize(): mixed
{
}
public function jsonSerialize(): mixed {}
}

View File

@ -13,29 +13,21 @@ use OCP\IDBConnection;
*/
class EpisodeActionMapper extends QBMapper
{
public function __construct(IDBConnection $db)
{
}
public function __construct(IDBConnection $db) {}
/**
* @return EpisodeActionEntity[]
* @throws Exception
*/
public function findAll(int $sinceTimestamp, string $userId)
{
}
public function findAll(int $sinceTimestamp, string $userId) {}
/**
* @return ?EpisodeActionEntity
*/
public function findByEpisodeUrl(string $episodeIdentifier, string $userId)
{
}
public function findByEpisodeUrl(string $episodeIdentifier, string $userId) {}
/**
* @return ?EpisodeActionEntity
*/
public function findByGuid(string $guid, string $userId)
{
}
public function findByGuid(string $guid, string $userId) {}
}

View File

@ -8,32 +8,22 @@ use OCA\GPodderSync\Core\EpisodeAction\EpisodeAction;
class EpisodeActionRepository
{
public function __construct(private EpisodeActionMapper $episodeActionMapper)
{
}
public function __construct(private EpisodeActionMapper $episodeActionMapper) {}
/**
* @return EpisodeAction[]
*/
public function findAll(int $sinceEpoch, string $userId)
{
}
public function findAll(int $sinceEpoch, string $userId) {}
/**
* @return ?EpisodeAction
*/
public function findByEpisodeUrl(string $episodeUrl, string $userId)
{
}
public function findByEpisodeUrl(string $episodeUrl, string $userId) {}
/**
* @return ?EpisodeAction
*/
public function findByGuid(string $guid, string $userId)
{
}
public function findByGuid(string $guid, string $userId) {}
public function deleteEpisodeActionByEpisodeUrl(string $episodeUrl, string $userId): void
{
}
public function deleteEpisodeActionByEpisodeUrl(string $episodeUrl, string $userId): void {}
}

View File

@ -8,23 +8,17 @@ use OCP\DB\Exception;
class EpisodeActionWriter
{
public function __construct(private EpisodeActionMapper $episodeActionMapper)
{
}
public function __construct(private EpisodeActionMapper $episodeActionMapper) {}
/**
* @return EpisodeActionEntity
* @throws Exception
*/
public function save(EpisodeActionEntity $episodeActionEntity)
{
}
public function save(EpisodeActionEntity $episodeActionEntity) {}
/**
* @return EpisodeActionEntity
* @throws Exception
*/
public function update(EpisodeActionEntity $episodeActionEntity)
{
}
public function update(EpisodeActionEntity $episodeActionEntity) {}
}

View File

@ -11,7 +11,5 @@ class SubscriptionChangeEntity extends Entity implements \JsonSerializable
/**
* @return array<string,mixed>
*/
public function jsonSerialize(): mixed
{
}
public function jsonSerialize(): mixed {}
}

View File

@ -12,32 +12,22 @@ use OCP\IDBConnection;
*/
class SubscriptionChangeMapper extends QBMapper
{
public function __construct(IDBConnection $db)
{
}
public function __construct(IDBConnection $db) {}
/**
* @return SubscriptionChangeEntity[]
*/
public function findAll(string $userId)
{
}
public function findAll(string $userId) {}
/**
* @return ?SubscriptionChangeEntity
*/
public function findByUrl(string $url, string $userId)
{
}
public function findByUrl(string $url, string $userId) {}
public function remove(SubscriptionChangeEntity $subscriptionChangeEntity): void
{
}
public function remove(SubscriptionChangeEntity $subscriptionChangeEntity): void {}
/**
* @return SubscriptionChangeEntity[]
*/
public function findAllSubscriptionState(bool $subscribed, \DateTime $sinceTimestamp, string $userId)
{
}
public function findAllSubscriptionState(bool $subscribed, \DateTime $sinceTimestamp, string $userId) {}
}

View File

@ -6,35 +6,25 @@ namespace OCA\GPodderSync\Db\SubscriptionChange;
class SubscriptionChangeRepository
{
public function __construct(private SubscriptionChangeMapper $subscriptionChangeMapper)
{
}
public function __construct(private SubscriptionChangeMapper $subscriptionChangeMapper) {}
/**
* @return SubscriptionChangeEntity[]
*/
public function findAll()
{
}
public function findAll() {}
/**
* @return ?SubscriptionChangeEntity
*/
public function findByUrl(string $episode, string $userId)
{
}
public function findByUrl(string $episode, string $userId) {}
/**
* @return SubscriptionChangeEntity[]
*/
public function findAllSubscribed(\DateTime $sinceTimestamp, string $userId)
{
}
public function findAllSubscribed(\DateTime $sinceTimestamp, string $userId) {}
/**
* @return SubscriptionChangeEntity[]
*/
public function findAllUnSubscribed(\DateTime $sinceTimestamp, string $userId)
{
}
public function findAllUnSubscribed(\DateTime $sinceTimestamp, string $userId) {}
}

View File

@ -6,25 +6,17 @@ namespace OCA\GPodderSync\Db\SubscriptionChange;
class SubscriptionChangeWriter
{
public function __construct(private SubscriptionChangeMapper $subscriptionChangeMapper)
{
}
public function __construct(private SubscriptionChangeMapper $subscriptionChangeMapper) {}
public function purge(): void
{
}
public function purge(): void {}
/**
* @return SubscriptionChangeEntity
*/
public function create(SubscriptionChangeEntity $subscriptionChangeEntity)
{
}
public function create(SubscriptionChangeEntity $subscriptionChangeEntity) {}
/**
* @return SubscriptionChangeEntity
*/
public function update(SubscriptionChangeEntity $subscriptionChangeEntity)
{
}
public function update(SubscriptionChangeEntity $subscriptionChangeEntity) {}
}