Completed
Push — master ( df25c8...b25810 )
by Pavel
02:03
created

ParametersHandler::buildParameters()   B

Complexity

Conditions 4
Paths 4

Size

Total Lines 24
Code Lines 15

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 20

Importance

Changes 1
Bugs 0 Features 0
Metric Value
dl 0
loc 24
ccs 0
cts 20
cp 0
rs 8.6845
c 1
b 0
f 0
cc 4
eloc 15
nc 4
nop 1
crap 20
1
<?php
2
3
namespace Paro\BuildParametersHandler;
4
5
use Composer\Script\Event;
6
7
class ParametersHandler
8
{
9
    public static function buildParameters(Event $event)
10
    {
11
        $extras = $event->getComposer()->getPackage()->getExtra();
12
        if (!isset($extras['build-parameters'])) {
13
            throw new \InvalidArgumentException('The parameter handler needs to be configured through the extra.build-parameters setting.');
14
        }
15
        $configs = $extras['build-parameters'];
16
        if (!is_array($configs)) {
17
            throw new \InvalidArgumentException('The extra.build-parameters setting must be an array or a configuration object.');
18
        }
19
20
	    $fileHandler = new FileHandler($event->getIO());
0 ignored issues
show
Unused Code introduced by
The call to FileHandler::__construct() has too many arguments starting with $event->getIO().

This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue.

If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress.

In this case you can add the @ignore PhpDoc annotation to the duplicate definition and it will be ignored.

Loading history...
21
22
        if (!isset($configs['build-folder'])) {
23
            $configs['build-folder'] = 'build';
24
        }
25
        $fileHandler->initDirectory($configs['build-folder']);
26
27
	    $fileProcessor = new FileProcessor($event->getIO(), $fileHandler);
28
        $fileProcessor->process($configs, $event);
29
30
        $incenteevProcessor = new IncenteevParametersProcessor($event->getIO(), $fileHandler);
31
        $incenteevProcessor->process($configs, $event);
32
    }
33
}