ConfigFileProcessor::convertConfigFile()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 7
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 4
c 1
b 0
f 0
dl 0
loc 7
rs 10
cc 1
nc 1
nop 1
1
<?php
2
3
declare(strict_types=1);
4
/**
5
 * ConfigFileProcessor.php
6
 * Copyright (c) 2020 [email protected].
7
 *
8
 * This file is part of the Firefly III bunq importer
9
 * (https://github.com/firefly-iii/bunq-importer).
10
 *
11
 * This program is free software: you can redistribute it and/or modify
12
 * it under the terms of the GNU Affero General Public License as
13
 * published by the Free Software Foundation, either version 3 of the
14
 * License, or (at your option) any later version.
15
 *
16
 * This program is distributed in the hope that it will be useful,
17
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
19
 * GNU Affero General Public License for more details.
20
 *
21
 * You should have received a copy of the GNU Affero General Public License
22
 * along with this program.  If not, see <https://www.gnu.org/licenses/>.
23
 */
24
25
namespace App\Services\Configuration;
26
27
use App\Services\Storage\StorageService;
28
use Illuminate\Contracts\Filesystem\FileNotFoundException;
29
30
/**
31
 * Class ConfigFileProcessor.
32
 */
33
class ConfigFileProcessor
34
{
35
    /**
36
     * Input (the content of) a configuration file and this little script will convert it to a compatible array.
37
     *
38
     * @param string $fileName
39
     *
40
     * @throws FileNotFoundException
41
     * @return Configuration
42
     */
43
    public static function convertConfigFile(string $fileName): Configuration
44
    {
45
        app('log')->debug('Now in ConfigFileProcessor::convertConfigFile');
46
        $content = StorageService::getContent($fileName);
47
        $json    = json_decode($content, true, 512, JSON_THROW_ON_ERROR);
48
49
        return Configuration::fromFile($json);
50
    }
51
}
52