30 lines
No EOL
664 B
PHP
30 lines
No EOL
664 B
PHP
<?php
|
|
|
|
namespace App\Services;
|
|
|
|
use App\Exceptions\RoutingMismatchException;
|
|
use App\Models\Feed;
|
|
use Illuminate\Support\Collection;
|
|
|
|
class RoutingValidationService
|
|
{
|
|
/**
|
|
* @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);
|
|
}
|
|
}
|
|
}
|
|
} |