2021-06-27 13:19:26 +02:00
|
|
|
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
|
|
|
|
namespace OCA\GPodderSync\Core\SubscriptionChange;
|
|
|
|
|
|
|
|
class SubscriptionChangesReader {
|
|
|
|
|
|
|
|
/**
|
2021-07-13 21:36:34 +02:00
|
|
|
* @param array $urls
|
|
|
|
* @param bool $subscribed
|
2021-06-27 13:19:26 +02:00
|
|
|
*
|
2021-07-13 21:36:34 +02:00
|
|
|
* @return SubscriptionChange[]
|
2021-06-27 13:19:26 +02:00
|
|
|
*/
|
2021-07-13 21:36:34 +02:00
|
|
|
public static function mapToSubscriptionsChanges(array $urls, bool $subscribed): array {
|
2021-06-27 13:19:26 +02:00
|
|
|
$subscriptionChanges = [];
|
2021-12-09 20:19:35 +01:00
|
|
|
$urls = array_filter($urls, function(string $url) {return filter_var($url, FILTER_VALIDATE_URL) !== false; });
|
2021-07-13 21:36:34 +02:00
|
|
|
foreach ($urls as $url) {
|
2021-06-27 13:19:26 +02:00
|
|
|
$subscriptionChanges[] = new SubscriptionChange($url, $subscribed);
|
|
|
|
}
|
|
|
|
|
|
|
|
return $subscriptionChanges;
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|