RequestModifierPipeline   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 21
Duplicated Lines 0 %

Test Coverage

Coverage 57.14%

Importance

Changes 0
Metric Value
eloc 7
dl 0
loc 21
ccs 4
cts 7
cp 0.5714
rs 10
c 0
b 0
f 0
wmc 3

2 Methods

Rating   Name   Duplication   Size   Complexity  
A process() 0 7 2
A pipe() 0 5 1
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