EmailSettingsMapper   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 30
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 3

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 4
lcom 0
cbo 3
dl 0
loc 30
ccs 9
cts 9
cp 1
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A export() 0 8 1
A import() 0 12 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 Email Settings Mapper.
12
 *
13
 * Sync Craft Setups.
14
 *
15
 * @author    Nerds & Company
16
 * @copyright Copyright (c) 2015-2019, 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