Failed Conditions
Push — master ( dc4e55...720050 )
by Florent
19:46 queued 13:33
created

ScopePolicyDefaultRule::handle()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 9
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 9
rs 9.6666
c 0
b 0
f 0
cc 2
eloc 5
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 ScopePolicyDefaultRule 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('default_scope')) {
28
            Assertion::regex($commandParameters->get('default_scope'), '/^[\x20\x23-\x5B\x5D-\x7E]+$/', 'Invalid characters found in the \'default_scope\' parameter.');
29
            $validatedParameters = $validatedParameters->with('default_scope', $commandParameters->get('default_scope'));
30
        }
31
32
        return $next($commandParameters, $validatedParameters, $userAccountId);
33
    }
34
}
35