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

ParametersHandler   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 27
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 5

Test Coverage

Coverage 0%

Importance

Changes 2
Bugs 0 Features 0
Metric Value
wmc 4
lcom 0
cbo 5
dl 0
loc 27
ccs 0
cts 20
cp 0
rs 10
c 2
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
B buildParameters() 0 24 4
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
}