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 {
|
2021-10-07 12:33:16 +00:00
|
|
|
$urlsToSubscribe = $this->subscriptionChangeReader::mapToSubscriptionsChanges($urlsSubscribed, true);
|
|
|
|
$urlsToDelete = $this->subscriptionChangeReader::mapToSubscriptionsChanges($urlsUnsubscribed, false);
|
2021-06-27 11:19:26 +00:00
|
|
|
|
2021-10-07 12:33:16 +00:00
|
|
|
/** @var SubscriptionChange[] $subscriptionChanges */
|
2021-06-27 11:19:26 +00:00
|
|
|
return array_merge($urlsToSubscribe, $urlsToDelete);
|
|
|
|
}
|
|
|
|
}
|