Test Setup Failed
Pull Request — master (#3)
by Timur
01:59
created

DocBlockTrait::removeDocBlock()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 2
c 0
b 0
f 0
nc 1
nop 0
dl 0
loc 5
rs 10
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Murtukov\PHPCodeGenerator;
6
7
trait DocBlockTrait
8
{
9
    protected ?Comment $docBlock = null;
10
11
    public function getDocBlock(): Comment
12
    {
13
        return $this->docBlock;
0 ignored issues
show
Bug Best Practice introduced by
The expression return $this->docBlock could return the type null which is incompatible with the type-hinted return Murtukov\PHPCodeGenerator\Comment. Consider adding an additional type-check to rule them out.
Loading history...
14
    }
15
16
    public function setDocBlock(string $text): self
17
    {
18
        $this->docBlock = Comment::docBlock($text);
19
20
        return $this;
21
    }
22
23
    public function createDocBlock(string $text = ''): Comment
24
    {
25
        return $this->docBlock = Comment::docBlock($text);
26
    }
27
28
    public function removeDocBlock(): self
29
    {
30
        $this->docBlock = null;
31
32
        return $this;
33
    }
34
35
    protected function buildDocBlock()
36
    {
37
        $code = '';
38
39
        if (null !== $this->docBlock) {
40
            $code = "$this->docBlock\n";
41
        }
42
43
        return $code;
44
    }
45
}
46