Documentor::__toString()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 10
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 10
rs 9.4286
cc 2
eloc 6
nc 2
nop 0
1
<?php
2
3
namespace Saxulum\PhpDocGenerator;
4
5
class Documentor
6
{
7
    /**
8
     * @var AbstractRow[]
9
     */
10
    protected $rows;
11
12
    /**
13
     * @param array $rows
14
     */
15
    public function __construct(array $rows)
16
    {
17
        if (count($rows) === 0) {
18
            throw new \InvalidArgumentException('At least one row needs to be given!');
19
        }
20
21
        foreach ($rows as $row) {
22
            if (!$row instanceof AbstractRow) {
23
                throw new \InvalidArgumentException('Rows have to extend AbstractRow!');
24
            }
25
26
            $this->rows[] = $row;
27
        }
28
    }
29
30
    /**
31
     * @return string
32
     */
33
    public function __toString()
34
    {
35
        $string = '/**'.PHP_EOL;
36
        foreach ($this->rows as $row) {
37
            $string .= ' * '.(string) $row.PHP_EOL;
38
        }
39
        $string .= ' */';
40
41
        return $string;
42
    }
43
}
44