Completed
Push — master ( d75c1f...eed677 )
by Viacheslav
12s
created

Description::renderDescriptionAsPhpDoc()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 7
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 2.2559

Importance

Changes 0
Metric Value
cc 2
eloc 5
nc 2
nop 0
dl 0
loc 7
ccs 3
cts 5
cp 0.6
crap 2.2559
rs 9.4285
c 0
b 0
f 0
1
<?php
2
3
namespace Swaggest\PhpCodeBuilder\Traits;
4
5
6
use Swaggest\PhpCodeBuilder\PhpDoc;
7
8
trait Description
9
{
10
    use PhpDocable;
11
12
    /** @var string */
13
    private $description;
14
15
    /**
16
     * @return string
17
     */
18
    public function getDescription()
19
    {
20
        return $this->description;
21
    }
22
23
    /**
24
     * @param string $description
25
     * @return $this
26
     */
27 3
    public function setDescription($description)
28
    {
29 3
        $this->description = $description;
30 3
        return $this;
31
    }
32
33 2
    private function renderDescriptionAsPhpDoc()
34
    {
35 2
        if ($this->description) {
36
            $this->getPhpDoc()->prepend(null, trim($this->description));
37
            return $this->getPhpDoc()->render();
38
        } else {
39 2
            return '';
40
        }
41
    }
42
43
}