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

ExtensionManager   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 45
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

Changes 0
Metric Value
wmc 5
lcom 1
cbo 1
dl 0
loc 45
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A add() 0 4 1
A processBefore() 0 8 2
A processAfter() 0 8 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