Completed
Push — master ( 2a5486...81459b )
by Vitaly
02:39
created

CommentsGenerator   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 21
Duplicated Lines 71.43 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

Changes 0
Metric Value
wmc 2
lcom 1
cbo 1
dl 15
loc 21
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A code() 15 15 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 declare(strict_types = 1);
2
/**
3
 * Created by Vitaly Iegorov <[email protected]>.
4
 * on 03.09.16 at 13:02
5
 */
6
namespace samsonphp\generator;
7
8
/**
9
 * Comments block generator.
10
 *
11
 * @author Vitaly Egorov <[email protected]>
12
 */
13
class CommentsGenerator extends AbstractGenerator
14
{
15
    /**
16
     * {@inheritdoc}
17
     */
18 View Code Duplication
    public function code($indentation = 0) : string
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in 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...
19
    {
20
        $innerIndentation = $this->indentation(1).' * ';
21
22
        $formattedCode = ['/**'];
23
24
        // Prepend inner indentation to code
25
        foreach ($this->code as $codeLine) {
26
            $formattedCode[] = $innerIndentation . $codeLine;
27
        }
28
29
        $formattedCode[] = '**/';
30
31
        return implode("\n" . $this->indentation($indentation), $formattedCode);
32
    }
33
}
34