2021-06-27 11:19:26 +00:00
|
|
|
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
|
|
|
|
namespace OCA\GPodderSync\Core\SubscriptionChange;
|
|
|
|
|
|
|
|
class SubscriptionChangeRequestParser {
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @var SubscriptionChangesReader
|
|
|
|
*/
|
|
|
|
private SubscriptionChangesReader $subscriptionChangeReader;
|
|
|
|
|
|
|
|
public function __construct(SubscriptionChangesReader $subscriptionChangeReader) {
|
|
|
|
$this->subscriptionChangeReader = $subscriptionChangeReader;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2021-07-13 19:36:34 +00:00
|
|
|
* @param array $urlsSubscribed
|
|
|
|
* @param array $urlsUnsubscribed
|
2021-06-27 11:19:26 +00:00
|
|
|
*
|
|
|
|
* @return SubscriptionChange[]
|
|
|
|
*/
|
2021-07-13 19:36:34 +00:00
|
|
|
public function createSubscriptionChangeList(array $urlsSubscribed, array $urlsUnsubscribed): array {
|
|
|
|
$urlsToSubscribe = $this->subscriptionChangeReader->mapToSubscriptionsChanges($urlsSubscribed, true);
|
|
|
|
$urlsToDelete = $this->subscriptionChangeReader->mapToSubscriptionsChanges($urlsUnsubscribed, false);
|
2021-06-27 11:19:26 +00:00
|
|
|
|
|
|
|
/** @var \OCA\GPodderSync\Core\SubscriptionChange\SubscriptionChange[] $subscriptionChanges */
|
|
|
|
return array_merge($urlsToSubscribe, $urlsToDelete);
|
|
|
|
}
|
|
|
|
}
|