AbstractRow::__toString()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 9
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 9
rs 9.6667
cc 2
eloc 5
nc 2
nop 0
1
<?php
2
3
namespace Saxulum\PhpDocGenerator;
4
5
abstract class AbstractRow
6
{
7
    /**
8
     * @var string[]
9
     */
10
    protected $parts = array();
11
12
    /**
13
     * @param string|null $part
14
     * @param string|null $prefix
15
     * @param string|null $suffix
16
     */
17
    protected function addPart($part, $prefix = null, $suffix = null)
18
    {
19
        if (null !== $part) {
20
            if (null !== $prefix) {
21
                $part = $prefix.$part;
22
            }
23
            if (null !== $suffix) {
24
                $part = $part.$suffix;
25
            }
26
27
            $this->parts[] = $part;
28
        }
29
    }
30
31
    /**
32
     * @return string
33
     */
34
    public function __toString()
35
    {
36
        $string = '@'.$this->getName();
37
        foreach ($this->parts as $part) {
38
            $string .= ' '.$part;
39
        }
40
41
        return $string;
42
    }
43
44
    /**
45
     * @return string
46
     */
47
    abstract public function getName();
48
}
49