fedi-feed-router/app/Services/RoutingValidationService.php

32 lines
753 B
PHP
Raw Normal View History

2025-07-05 18:26:04 +02:00
<?php
namespace App\Services;
use App\Exceptions\RoutingMismatchException;
use App\Models\Feed;
2025-07-07 00:51:32 +02:00
use App\Models\PlatformChannel;
2025-07-05 18:26:04 +02:00
use Illuminate\Support\Collection;
class RoutingValidationService
{
/**
2025-07-07 00:51:32 +02:00
* @param Collection<int, PlatformChannel> $channels
2025-07-05 18:26:04 +02:00
* @throws RoutingMismatchException
*/
public function validateLanguageCompatibility(Feed $feed, Collection $channels): void
{
if (! $feed->language) {
return;
}
foreach ($channels as $channel) {
if (! $channel->language) {
continue;
}
if ($feed->language !== $channel->language) {
throw new RoutingMismatchException($feed, $channel);
}
}
}
}