ClassConstantGenerator::code()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 14
Code Lines 8

Duplication

Lines 3
Ratio 21.43 %

Code Coverage

Tests 7
CRAP Score 2.0078

Importance

Changes 0
Metric Value
dl 3
loc 14
ccs 7
cts 8
cp 0.875
rs 9.4285
c 0
b 0
f 0
cc 2
eloc 8
nc 2
nop 0
crap 2.0078
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