PresetsAwareTrait   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 30
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
A loadPreset() 0 4 1
A loadPresets() 0 8 2
1
<?php
2
3
namespace Schnittstabil\ComposerExtra;
4
5
/**
6
 * Load additional presets.
7
 */
8
trait PresetsAwareTrait
9
{
10
    /**
11
     * Load single preset.
12
     *
13
     * @param mixed $preset preset to load
14
     *
15
     * @return array configuration of preset
16
     */
17
    protected function loadPreset($preset)
18
    {
19
        return call_user_func($preset);
20
    }
21
22
    /**
23
     * Load presets.
24
     *
25
     * @param mixed $presets presets to load
26
     *
27
     * @return array preset configurations
28
     */
29
    protected function loadPresets($presets)
30
    {
31
        if (empty($presets)) {
32
            return [];
33
        }
34
35
        return array_map([$this, 'loadPreset'], $presets);
36
    }
37
}
38