RequestModifierPipeline::process()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 7
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 2

Importance

Changes 0
Metric Value
cc 2
eloc 3
nc 2
nop 1
dl 0
loc 7
ccs 4
cts 4
cp 1
crap 2
rs 10
c 0
b 0
f 0
1
<?php
2
/**
3
 * php-guard/curl <https://github.com/php-guard/curl>
4
 * Copyright (C) ${YEAR} by Alexandre Le Borgne <[email protected]>.
5
 *
6
 * This program is free software: you can redistribute it and/or modify
7
 * it under the terms of the GNU General Public License as published by
8
 * the Free Software Foundation, either version 3 of the License, or
9
 * (at your option) any later version.
10
 *
11
 * This program is distributed in the hope that it will be useful,
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
 * GNU General Public License for more details.
15
 *
16
 * You should have received a copy of the GNU General Public License
17
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
18
 */
19
20
namespace PhpGuard\Curl;
21
22
use PhpGuard\Curl\RequestModifier\RequestModifierInterface;
23
24
class RequestModifierPipeline
25
{
26
    /**
27
     * @var RequestModifierInterface[]
28
     */
29
    private $requestModifiers = [];
30
31
    public function pipe(RequestModifierInterface $requestModifier): self
32
    {
33
        $this->requestModifiers[] = $requestModifier;
34
35
        return $this;
36
    }
37
38 45
    public function process(CurlRequest $curlRequest)
39
    {
40 45
        foreach ($this->requestModifiers as $requestModifier) {
41 45
            $curlRequest = $requestModifier->modify($curlRequest);
42
        }
43
44 45
        return $curlRequest;
45
    }
46
}
47