Passed
Push — master ( 35c1b5...e11383 )
by Théo
01:52
created

Configuration::retrieveWhitelist()   B

Complexity

Conditions 11
Paths 32

Size

Total Lines 79
Code Lines 47

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 17
CRAP Score 35.2741

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 11
eloc 47
c 1
b 0
f 0
nc 32
nop 1
dl 0
loc 79
ccs 17
cts 41
cp 0.4146
crap 35.2741
rs 7.3166

How to fix   Long Method    Complexity   

Long Method

Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.

For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.

Commonly applied refactorings include:

1
<?php
2
3
declare(strict_types=1);
4
5
/*
6
 * This file is part of the humbug/php-scoper package.
7
 *
8
 * Copyright (c) 2017 Théo FIDRY <[email protected]>,
9
 *                    Pádraic Brady <[email protected]>
10
 *
11
 * For the full copyright and license information, please view the LICENSE
12
 * file that was distributed with this source code.
13
 */
14
15
namespace Humbug\PhpScoper;
16
17
final class Configuration
18
{
19
    private ?string $path;
20
    private string $prefix;
21
    private array $filesWithContents;
22
    private array $patchers;
23
    private Whitelist $whitelist;
24
    private array $whitelistedFiles;
25
26
    /**
27
     * @param string|null $path                   Absolute path to the configuration file loaded.
28
     * @param string      $prefix                 The prefix applied.
29
     * @param array<string, array{string, string}> $filesWithContents      Array of tuple with the
1 ignored issue
show
Documentation Bug introduced by
The doc comment array<string, array{string, string}> at position 6 could not be parsed: Expected ':' at position 6, but found 'string'.
Loading history...
30
     *                                            first argument being the file path and the second
31
     *                                            its contents
32
     * @param callable[]  $patchers               List of closures which can alter the content of
33
     *                                            the files being scoped.
34
     * @param Whitelist   $whitelist              List of classes that will not be scoped.
35
     *                                            returning a boolean which if `true` means the
36
     *                                            class should be scoped
37
     *                                            (i.e. is ignored) or scoped otherwise.
38
     * @param string[]    $whitelistedFiles       List of absolute paths of files to completely
39
     *                                            ignore
40
     */
41
    public function __construct(
42
        ?string $path,
43
        string $prefix,
44
        array $filesWithContents,
45
        array $patchers,
46
        Whitelist $whitelist,
47
        array $whitelistedFiles
48
    ) {
49
        $this->path = $path;
50
        $this->prefix = $prefix;
51
        $this->filesWithContents = $filesWithContents;
52
        $this->patchers = $patchers;
53
        $this->whitelist = $whitelist;
54
        $this->whitelistedFiles = $whitelistedFiles;
55
    }
56
57
    public function getPath(): ?string
58
    {
59
        return $this->path;
60
    }
61
62
    public function getPrefix(): string
63
    {
64
        return $this->prefix;
65
    }
66
67
    /**
68
     * @return array<string, array{string, string}>
1 ignored issue
show
Documentation Bug introduced by
The doc comment array<string, array{string, string}> at position 6 could not be parsed: Expected ':' at position 6, but found 'string'.
Loading history...
69
     */
70
    public function getFilesWithContents(): array
71
    {
72
        return $this->filesWithContents;
73
    }
74
75
    /**
76
     * @return callable[]
77
     */
78
    public function getPatchers(): array
79 3
    {
80
        return $this->patchers;
81 3
    }
82 1
83
    public function getWhitelist(): Whitelist
84 2
    {
85
        return $this->whitelist;
86
    }
87
88
    /**
89
     * @return string[]
90
     */
91
    public function getWhitelistedFiles(): array
92
    {
93
        return $this->whitelistedFiles;
94 2
    }
95
}
96