Completed
Push — master ( 4f2fad...dd1cd3 )
by Guillaume
07:10
created

ConfigurationDumper   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 19
Duplicated Lines 15.79 %

Coupling/Cohesion

Components 0
Dependencies 1
Metric Value
wmc 2
lcom 0
cbo 1
dl 3
loc 19
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A dumpConfiguration() 3 9 2

How to fix   Duplicated Code   

Duplicated Code

Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.

Common duplication problems, and corresponding solutions are:

1
<?php
2
3
namespace Hogosha\Monitor\Configuration;
4
5
use Symfony\Component\Yaml\Yaml;
6
7
class ConfigurationDumper
8
{
9
    /**
10
     * Dump configuration array to valid file content.
11
     *
12
     * @param array $config The configuration
13
     *
14
     * @return string The dumped configuration
15
     */
16
    public function dumpConfiguration(array $config)
17
    {
18
        $content = '';
19 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...
20
            $content .= Yaml::dump([$name => $section], 4).PHP_EOL;
21
        }
22
23
        return $content;
24
    }
25
}
26