Failed Conditions
Push — master ( d3ed62...7f2d83 )
by Florent
281:43 queued 02:00
created

ExtensionManager::add()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 1
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\AuthorizationEndpoint\Extension;
15
16
use OAuth2Framework\Component\AuthorizationEndpoint\Authorization;
17
use Psr\Http\Message\ServerRequestInterface;
18
19
class ExtensionManager
20
{
21
    /**
22
     * @var Extension[]
23
     */
24
    private $extensions = [];
25
26
    public function add(Extension $extension): void
27
    {
28
        $this->extensions[] = $extension;
29
    }
30
31
    public function processBefore(ServerRequestInterface $request, Authorization $authorization): Authorization
32
    {
33
        foreach ($this->extensions as $extension) {
34
            $extension->processBefore($request, $authorization);
35
        }
36
37
        return $authorization;
38
    }
39
40
    public function processAfter(ServerRequestInterface $request, Authorization $authorization): Authorization
41
    {
42
        foreach ($this->extensions as $extension) {
43
            $extension->processAfter($request, $authorization);
44
        }
45
46
        return $authorization;
47
    }
48
}
49