Completed
Push — master ( 60f6d2...2121c5 )
by
unknown
12s queued 10s
created

EmailSettingsMapper::import()   A

Complexity

Conditions 3
Paths 3

Size

Total Lines 12
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 6
CRAP Score 3

Importance

Changes 0
Metric Value
dl 0
loc 12
ccs 6
cts 6
cp 1
rs 9.4285
c 0
b 0
f 0
cc 3
eloc 6
nc 3
nop 2
crap 3
1
<?php
2
3
namespace NerdsAndCompany\Schematic\Mappers;
4
5
use Craft;
6
use NerdsAndCompany\Schematic\Schematic;
7
use NerdsAndCompany\Schematic\Interfaces\MapperInterface;
8
use yii\base\Component as BaseComponent;
9
10
/**
11
 * Schematic System Settings Mapper.
12
 *
13
 * Sync Craft Setups.
14
 *
15
 * @author    Nerds & Company
16
 * @copyright Copyright (c) 2015-2018, Nerds & Company
17
 * @license   MIT
18
 *
19
 * @see      http://www.nerds.company
20
 */
21
class EmailSettingsMapper extends BaseComponent implements MapperInterface
22
{
23
    /**
24
     * {@inheritdoc}
25
     */
26 1
    public function export(array $settings = []): array
27
    {
28 1
        $settings = Craft::$app->systemSettings->getSettings('email');
29
30
        return [
31 1
            'settings' => $settings,
32
        ];
33
    }
34
35
    /**
36
     * {@inheritdoc}
37
     */
38 1
    public function import(array $emailSettings, array $settings = []): array
39
    {
40 1
        if (array_key_exists('settings', $emailSettings)) {
41 1
            Schematic::info('- Saving email settings');
42
43 1
            if (!Craft::$app->systemSettings->saveSettings('email', $emailSettings['settings'])) {
44 1
                Schematic::warning('- Couldn’t save email settings.');
45
            }
46
        }
47
48 1
        return [];
49
    }
50
}
51