1 | <?php |
||
21 | class Serializer |
||
22 | { |
||
23 | /** @var string The string to indent the comment with. */ |
||
24 | protected $indentString = ' '; |
||
25 | |||
26 | /** @var int The number of times the indent string is repeated. */ |
||
27 | protected $indent = 0; |
||
28 | |||
29 | /** @var bool Whether to indent the first line with the given indent amount and string. */ |
||
30 | protected $isFirstLineIndented = true; |
||
31 | |||
32 | /** @var int|null The max length of a line. */ |
||
33 | protected $lineLength = null; |
||
34 | |||
35 | /** @var DocBlock\Tags\Formatter A custom tag formatter. */ |
||
36 | protected $tagFormatter = null; |
||
37 | |||
38 | /** |
||
39 | * Create a Serializer instance. |
||
40 | * |
||
41 | * @param int $indent The number of times the indent string is repeated. |
||
42 | * @param string $indentString The string to indent the comment with. |
||
43 | * @param bool $indentFirstLine Whether to indent the first line. |
||
44 | * @param int|null $lineLength The max length of a line or NULL to disable line wrapping. |
||
45 | * @param DocBlock\Tags\Formatter $tagFormatter A custom tag formatter, defaults to PassthroughFormatter. |
||
46 | */ |
||
47 | 8 | public function __construct($indent = 0, $indentString = ' ', $indentFirstLine = true, $lineLength = null, $tagFormatter = null) |
|
61 | |||
62 | /** |
||
63 | * Generate a DocBlock comment. |
||
64 | * |
||
65 | * @param DocBlock $docblock The DocBlock to serialize. |
||
66 | * |
||
67 | * @return string The serialized doc block. |
||
68 | */ |
||
69 | 4 | public function getDocComment(DocBlock $docblock) |
|
95 | |||
96 | 4 | /** |
|
97 | * @param $indent |
||
98 | 4 | * @param $text |
|
99 | * @return mixed |
||
100 | */ |
||
101 | private function removeTrailingSpaces($indent, $text) |
||
105 | |||
106 | 4 | /** |
|
107 | * @param $indent |
||
108 | 4 | * @param $text |
|
109 | * @return mixed |
||
110 | */ |
||
111 | private function addAsterisksForEachLine($indent, $text) |
||
115 | |||
116 | 4 | /** |
|
117 | * @param DocBlock $docblock |
||
118 | 4 | * @param $wrapLength |
|
119 | 4 | * @return string |
|
120 | 4 | */ |
|
121 | 1 | private function getSummaryAndDescriptionTextBlock(DocBlock $docblock, $wrapLength) |
|
132 | |||
133 | /** |
||
134 | * @param DocBlock $docblock |
||
135 | 4 | * @param $wrapLength |
|
136 | * @param $indent |
||
137 | 4 | * @param $comment |
|
138 | 4 | * @return string |
|
139 | 4 | */ |
|
140 | 1 | private function addTagBlock(DocBlock $docblock, $wrapLength, $indent, $comment) |
|
155 | } |
||
156 |