Failed Conditions
Pull Request — master (#49)
by Florent
09:19 queued 04:26
created

ContactsParametersRule::handle()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 12
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 12
rs 9.4285
c 0
b 0
f 0
cc 2
eloc 7
nc 2
nop 4
1
<?php
2
3
declare(strict_types=1);
4
5
/*
6
 * The MIT License (MIT)
7
 *
8
 * Copyright (c) 2014-2017 Spomky-Labs
9
 *
10
 * This software may be modified and distributed under the terms
11
 * of the MIT license.  See the LICENSE file for details.
12
 */
13
14
namespace OAuth2Framework\Component\Server\Model\Client\Rule;
15
16
use Assert\Assertion;
17
use OAuth2Framework\Component\Server\Model\DataBag\DataBag;
18
use OAuth2Framework\Component\Server\Model\UserAccount\UserAccountId;
19
20
final class ContactsParametersRule implements RuleInterface
21
{
22
    /**
23
     * {@inheritdoc}
24
     */
25
    public function handle(DataBag $commandParameters, DataBag $validatedParameters, ? UserAccountId $userAccountId, callable $next): DataBag
26
    {
27
        if ($commandParameters->has('contacts')) {
28
            $contacts = $commandParameters->has('contacts');
29
            Assertion::isArray($contacts, 'The parameter \'contacts\' must be a list of e-mail addresses.');
30
            Assertion::allEmail($contacts, sprintf('The parameter \'contacts\' must be a list of e-mail addresses.', $k));
0 ignored issues
show
Bug introduced by
The variable $k does not exist. Did you forget to declare it?

This check marks access to variables or properties that have not been declared yet. While PHP has no explicit notion of declaring a variable, accessing it before a value is assigned to it is most likely a bug.

Loading history...
31
32
            $validatedParameters = $validatedParameters->with('contacts', $contacts);
33
        }
34
35
        return $next($commandParameters, $validatedParameters, $userAccountId);
36
    }
37
}
38