Failed Conditions
Push — ng ( ede6c5...efffe8 )
by Florent
11:50
created

ExtensionManager::processBefore()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 8
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 8
rs 9.4285
c 0
b 0
f 0
cc 2
eloc 4
nc 2
nop 2
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\Server\AuthorizationEndpoint\ConsentScreen;
15
16
use OAuth2Framework\Component\Server\AuthorizationEndpoint\Authorization;
17
use Psr\Http\Message\ServerRequestInterface;
18
19
final class ExtensionManager
20
{
21
    /**
22
     * @var Extension[]
23
     */
24
    private $extensions = [];
25
26
    /**
27
     * @param Extension $extension
28
     */
29
    public function add(Extension $extension)
30
    {
31
        $this->extensions[] = $extension;
32
    }
33
34
    /**
35
     * @param ServerRequestInterface $request
36
     * @param Authorization          $authorization
37
     *
38
     * @return Authorization
39
     */
40
    public function processBefore(ServerRequestInterface $request, Authorization $authorization): Authorization
41
    {
42
        foreach ($this->extensions as $extension) {
43
            $authorization = $extension->processBefore($request, $authorization);
44
        }
45
46
        return $authorization;
47
    }
48
49
    /**
50
     * @param ServerRequestInterface $request
51
     * @param Authorization          $authorization
52
     *
53
     * @return Authorization
54
     */
55
    public function processAfter(ServerRequestInterface $request, Authorization $authorization): Authorization
56
    {
57
        foreach ($this->extensions as $extension) {
58
            $authorization = $extension->processAfter($request, $authorization);
59
        }
60
61
        return $authorization;
62
    }
63
}
64