ConfigurationDumper::dumpConfiguration()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 9
Code Lines 5

Duplication

Lines 3
Ratio 33.33 %
Metric Value
cc 2
eloc 5
nc 2
nop 1
dl 3
loc 9
rs 9.6666
1
<?php
2
3
/*
4
 * This file is part of the hogosha-monitor package
5
 *
6
 * Copyright (c) 2016 Guillaume Cavana
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 *
11
 * Feel free to edit as you please, and have fun.
12
 *
13
 * @author Guillaume Cavana <[email protected]>
14
 */
15
16
namespace Hogosha\Monitor\Configuration;
17
18
use Symfony\Component\Yaml\Yaml;
19
20
class ConfigurationDumper
21
{
22
    /**
23
     * Dump configuration array to valid file content.
24
     *
25
     * @param array $config The configuration
26
     *
27
     * @return string The dumped configuration
28
     */
29
    public function dumpConfiguration(array $config)
30
    {
31
        $content = '';
32 View Code Duplication
        foreach ($config as $name => $section) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
33
            $content .= Yaml::dump([$name => $section], 4).PHP_EOL;
34
        }
35
36
        return $content;
37
    }
38
}
39