ClassConstantGenerator   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 20
Duplicated Lines 15 %

Coupling/Cohesion

Components 1
Dependencies 1

Test Coverage

Coverage 87.5%

Importance

Changes 0
Metric Value
wmc 2
lcom 1
cbo 1
dl 3
loc 20
ccs 7
cts 8
cp 0.875
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A code() 3 14 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 04.09.16 at 15:29
5
 */
6
namespace samsonframework\generator;
7
8
/**
9
 * Class ClassConstantGenerator
10
 *
11
 * @author Vitaly Egorov <[email protected]>
12
 */
13
class ClassConstantGenerator extends PropertyGenerator
14
{
15
    /**
16
     * @inheritdoc
17
     */
18 1
    public function code(): string
19
    {
20 1
        $code = $this->indentation($this->indentation)
21 1
            . 'const '
22 1
            . $this->name
23 1
            . ';';
24
25
        // Add comments
26 1 View Code Duplication
        if (array_key_exists(CommentsGenerator::class, $this->generatedCode)) {
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...
27
            $code = $this->generatedCode[CommentsGenerator::class] . "\n" . $code;
28
        }
29
30 1
        return $code;
31
    }
32
}
33