Conditions | 5 |
Paths | 4 |
Total Lines | 17 |
Code Lines | 10 |
Lines | 0 |
Ratio | 0 % |
Changes | 0 |
1 | <?php |
||
24 | public function handle(ClientId $clientId, DataBag $commandParameters, DataBag $validatedParameters, callable $next): DataBag |
||
25 | { |
||
26 | if ($commandParameters->has('contacts')) { |
||
27 | $contacts = $commandParameters->get('contacts'); |
||
28 | if (!is_array($contacts)) { |
||
29 | throw new \InvalidArgumentException('The parameter "contacts" must be a list of e-mail addresses.'); |
||
30 | } |
||
31 | foreach ($contacts as $contact) { |
||
32 | if (!filter_var($contact, FILTER_VALIDATE_EMAIL)) { |
||
33 | throw new \InvalidArgumentException('The parameter "contacts" must be a list of e-mail addresses.'); |
||
34 | } |
||
35 | } |
||
36 | $validatedParameters = $validatedParameters->with('contacts', $contacts); |
||
37 | } |
||
38 | |||
39 | return $next($clientId, $commandParameters, $validatedParameters); |
||
40 | } |
||
41 | } |
||
42 |