Failed Conditions
Push — ng ( 625bbc...a06888 )
by Florent
08:03
created

ClientIdIssuedAtRule::handle()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 10
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 10
rs 9.4285
c 0
b 0
f 0
cc 2
eloc 6
nc 2
nop 4
1
<?php
2
3
declare(strict_types=1);
4
5
/*
6
 * The MIT License (MIT)
7
 *
8
 * Copyright (c) 2014-2018 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\ClientRule;
15
16
use OAuth2Framework\Component\Core\Client\ClientId;
17
use OAuth2Framework\Component\Core\DataBag\DataBag;
18
19
class ClientIdIssuedAtRule implements Rule
20
{
21
    /**
22
     * {@inheritdoc}
23
     */
24
    public function handle(ClientId $clientId, DataBag $commandParameters, DataBag $validatedParameters, callable $next): DataBag
25
    {
26
        if ($commandParameters->has('client_id_issued_at')) {
27
            $validatedParameters = $validatedParameters->with('client_id_issued_at', $commandParameters->get('client_id_issued_at'));
28
        } else {
29
            $validatedParameters = $validatedParameters->with('client_id_issued_at', time());
30
        }
31
32
        return $next($clientId, $commandParameters, $validatedParameters);
33
    }
34
}
35