PHPStanAnalyseCommandBuilder::build()   F
last analyzed

Complexity

Conditions 12
Paths 1024

Size

Total Lines 34
Code Lines 22

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 23
CRAP Score 12

Importance

Changes 0
Metric Value
eloc 22
dl 0
loc 34
ccs 23
cts 23
cp 1
rs 2.8
c 0
b 0
f 0
cc 12
nc 1024
nop 1
crap 12

How to fix   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
/**
4
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
5
 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
6
 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
7
 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
8
 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
9
 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
10
 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
11
 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
12
 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
13
 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
14
 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
15
 *
16
 * This software consists of voluntary contributions made by many individuals
17
 * and is licensed under the LGPL. For more information please see
18
 * <http://phing.info>.
19
 */
20
21
declare(strict_types=1);
22
23
namespace Phing\Task\Ext\Analyzer\Phpstan\CommandBuilder;
24
25
use Phing\Task\Ext\Analyzer\Phpstan\PHPStanTask;
26
27
class PHPStanAnalyseCommandBuilder extends PHPStanCommandBuilder
28
{
29 6
    public function build(PHPStanTask $task): void
30
    {
31 6
        parent::build($task);
32
33 6
        $cmd = $task->getCommandline();
34
35 6
        if (!empty($task->getConfiguration())) {
36 2
            $cmd->createArgument()->setValue('--configuration=' . $task->getConfiguration());
37
        }
38 6
        if (!empty($task->getLevel())) {
39 2
            $cmd->createArgument()->setValue('--level=' . $task->getLevel());
40
        }
41 6
        if ($task->isNoProgress()) {
42 2
            $cmd->createArgument()->setValue('--no-progress');
43
        }
44 6
        if ($task->isDebug()) {
45 2
            $cmd->createArgument()->setValue('--debug');
46
        }
47 6
        if (!empty($task->getAutoloadFile())) {
48 2
            $cmd->createArgument()->setValue('--autoload-file=' . $task->getAutoloadFile());
49
        }
50 6
        if (!empty($task->getErrorFormat())) {
51 2
            $cmd->createArgument()->setValue('--error-format=' . $task->getErrorFormat());
52
        }
53 6
        if (!empty($task->getMemoryLimit())) {
54 2
            $cmd->createArgument()->setValue('--memory-limit=' . $task->getMemoryLimit());
55
        }
56 6
        if (!empty($task->getPaths())) {
57 2
            $cmd->createArgument()->setValue($task->getPaths());
58
        }
59 6
        if (count($task->getFileSets()) > 0) {
60 1
            foreach ($task->getFileSets() as $fs) {
61 1
                foreach ($fs as $file) {
62 1
                    $cmd->createArgument()->setValue($file);
63
                }
64
            }
65
        }
66
    }
67
}
68