Completed
Pull Request — master (#148)
by
unknown
20:40 queued 09:54
created

GeneralSettingsMapper::export()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 8
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1.037

Importance

Changes 0
Metric Value
dl 0
loc 8
ccs 2
cts 3
cp 0.6667
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 4
nc 1
nop 1
crap 1.037
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 General 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 GeneralSettingsMapper extends BaseComponent implements MapperInterface
22
{
23
    /**
24
     * {@inheritdoc}
25
     */
26 1
    public function export(array $info = []): array
27
    {
28 1
        $info = Craft::$app->getInfo();
29
30
        return [
31
            'info' => $info,
32
        ];
33
    }
34
35
    /**
36
     * {@inheritdoc}
37
     */
38 1
    public function import(array $info, array $settings = []): array
39
    {
40 1
        if (array_key_exists('info', $info)) {
41 1
            Schematic::info('- Saving general settings');
42
43 1
            if (!Craft::$app->saveInfo($info['info'])) {
44
                Schematic::warning('- Couldn’t save general settings.');
45
            }
46
        }
47
48
        return [];
49
    }
50
}
51