ScriptHandler   A
last analyzed

Complexity

Total Complexity 6

Size/Duplication

Total Lines 31
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 3

Importance

Changes 0
Metric Value
wmc 6
lcom 0
cbo 3
dl 0
loc 31
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
B buildParameters() 0 28 6
1
<?php
2
3
namespace Incenteev\ParameterHandler;
4
5
use Composer\Script\Event;
6
7
class ScriptHandler
8
{
9
    public static function buildParameters(Event $event)
10
    {
11
        $extras = $event->getComposer()->getPackage()->getExtra();
12
13
        if (!isset($extras['incenteev-parameters'])) {
14
            throw new \InvalidArgumentException('The parameter handler needs to be configured through the extra.incenteev-parameters setting.');
15
        }
16
17
        $configs = $extras['incenteev-parameters'];
18
19
        if (!is_array($configs)) {
20
            throw new \InvalidArgumentException('The extra.incenteev-parameters setting must be an array or a configuration object.');
21
        }
22
23
        if (array_keys($configs) !== range(0, count($configs) - 1)) {
24
            $configs = [$configs];
25
        }
26
27
        $processor = new Processor($event->getIO());
28
29
        foreach ($configs as $config) {
30
            if (!is_array($config)) {
31
                throw new \InvalidArgumentException('The extra.incenteev-parameters setting must be an array of configuration objects.');
32
            }
33
34
            $processor->processFile($config);
35
        }
36
    }
37
}
38