PresetsAwareTrait::loadPreset()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 1
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