Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
0.00% covered (danger)
0.00%
0 / 7
0.00% covered (danger)
0.00%
0 / 1
CRAP
0.00% covered (danger)
0.00%
0 / 1
RoutingValidationService
0.00% covered (danger)
0.00%
0 / 7
0.00% covered (danger)
0.00%
0 / 1
30
0.00% covered (danger)
0.00%
0 / 1
 validateLanguageCompatibility
0.00% covered (danger)
0.00%
0 / 7
0.00% covered (danger)
0.00%
0 / 1
30
1<?php
2
3namespace App\Services;
4
5use App\Exceptions\RoutingMismatchException;
6use App\Models\Feed;
7use App\Models\PlatformChannel;
8use Illuminate\Support\Collection;
9
10class RoutingValidationService
11{
12    /**
13     * @param Collection<int, PlatformChannel> $channels
14     * @throws RoutingMismatchException
15     */
16    public function validateLanguageCompatibility(Feed $feed, Collection $channels): void
17    {
18        if (! $feed->language) {
19            return;
20        }
21
22        foreach ($channels as $channel) {
23            if (! $channel->language) {
24                continue;
25            }
26
27            if ($feed->language !== $channel->language) {
28                throw new RoutingMismatchException($feed, $channel);
29            }
30        }
31    }
32}