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

Description   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 32
Duplicated Lines 0 %

Test Coverage

Coverage 60%

Importance

Changes 0
Metric Value
dl 0
loc 32
ccs 6
cts 10
cp 0.6
rs 10
c 0
b 0
f 0
wmc 4

3 Methods

Rating   Name   Duplication   Size   Complexity  
A setDescription() 0 4 1
A getDescription() 0 3 1
A renderDescriptionAsPhpDoc() 0 7 2
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
}