SettingsImporter::importSetting()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 10

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 7
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 10
ccs 7
cts 7
cp 1
rs 9.9332
c 0
b 0
f 0
cc 2
nc 2
nop 1
crap 2
1
<?php
2
3
namespace League\CLImate\Settings;
4
5
trait SettingsImporter
6
{
7
    /**
8
     * Dictates any settings that a class may need access to
9
     *
10
     * @return array
11
     */
12 488
    public function settings()
13
    {
14 488
        return [];
15
    }
16
17
    /**
18
     * Import the setting into the class
19
     *
20
     * @param \League\CLImate\Settings\SettingsInterface $setting
21
     */
22 44
    public function importSetting($setting)
23
    {
24 44
        $short_name = basename(str_replace('\\', '/', get_class($setting)));
25
26 44
        $method = 'importSetting' . $short_name;
27
28 44
        if (method_exists($this, $method)) {
29 44
            $this->$method($setting);
30 44
        }
31 44
    }
32
}
33