Completed
Push — master ( af4509...61a82f )
by Vitaly
03:33
created

ClassConstantGenerator::code()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 14
Code Lines 8

Duplication

Lines 3
Ratio 21.43 %

Importance

Changes 0
Metric Value
dl 3
loc 14
rs 9.4285
c 0
b 0
f 0
cc 2
eloc 8
nc 2
nop 1
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 samsonphp\generator;
7
8
/**
9
 * Class ClassConstantGenerator
10
 *
11
 * @author Vitaly Egorov <[email protected]>
12
 */
13
class ClassConstantGenerator extends PropertyGenerator
14
{
15
    /**
16
     * Generate code.
17
     *
18
     * @param int $indentation Code level
19
     *
20
     * @return string Generated code
21
     */
22
    public function code(int $indentation = 0) : string
23
    {
24
        $code = $this->indentation($this->indentation)
25
            . 'const '
26
            . $this->name
27
            . ';';
28
29
        // Add comments
30 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...
31
            $code = $this->generatedCode[CommentsGenerator::class] . "\n" . $code;
32
        }
33
34
        return $code;
35
    }
36
}
37