Passed
Pull Request — master (#562)
by Théo
01:56
created

PatcherChain::getPatchers()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 0
dl 0
loc 3
rs 10
c 0
b 0
f 0
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Humbug\PhpScoper\Patcher;
6
7
use function array_reduce;
8
9
final class PatcherChain implements Patcher
10
{
11
    /**
12
     * @var array<(callable(string, string, string): string)|Patcher>
0 ignored issues
show
Documentation Bug introduced by
The doc comment array<(callable(string, ...ring): string)|Patcher> at position 3 could not be parsed: Expected ')' at position 3, but found 'callable'.
Loading history...
13
     */
14
    private array $patchers;
15
16
    /**
17
     * @param array<callable(string, string, string): string> $patchers
0 ignored issues
show
Documentation Bug introduced by
The doc comment array<callable(string, string, string): string> at position 2 could not be parsed: Expected '>' at position 2, but found 'callable'.
Loading history...
18
     */
19
    public function __construct(array $patchers = [])
20
    {
21
        $this->patchers = $patchers;
22
    }
23
24
    public function __invoke(string $filePath, string $prefix, string $contents): string
25
    {
26
        return (string) array_reduce(
27
            $this->patchers,
28
            static fn (string $contents, callable $patcher) => $patcher($filePath, $prefix, $contents),
29
            $contents,
30
        );
31
    }
32
33
    /**
34
     * @internal
35
     *
36
     * @return array<(callable(string, string, string): string)|Patcher>
0 ignored issues
show
Documentation Bug introduced by
The doc comment array<(callable(string, ...ring): string)|Patcher> at position 3 could not be parsed: Expected ')' at position 3, but found 'callable'.
Loading history...
37
     */
38
    public function getPatchers(): array
39
    {
40
        return $this->patchers;
41
    }
42
}
43