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 | /** |
||
36 | * Create a Serializer instance. |
||
37 | * |
||
38 | * @param int $indent The number of times the indent string is repeated. |
||
39 | * @param string $indentString The string to indent the comment with. |
||
40 | * @param bool $indentFirstLine Whether to indent the first line. |
||
41 | * @param int|null $lineLength The max length of a line or NULL to disable line wrapping. |
||
42 | */ |
||
43 | 4 | public function __construct($indent = 0, $indentString = ' ', $indentFirstLine = true, $lineLength = null) |
|
55 | |||
56 | /** |
||
57 | * Generate a DocBlock comment. |
||
58 | * |
||
59 | * @param DocBlock $docblock The DocBlock to serialize. |
||
60 | * |
||
61 | * @return string The serialized doc block. |
||
62 | */ |
||
63 | 4 | public function getDocComment(DocBlock $docblock) |
|
84 | |||
85 | /** |
||
86 | * @param $indent |
||
87 | * @param $text |
||
88 | * @return mixed |
||
89 | */ |
||
90 | private function removeTrailingSpaces($indent, $text) |
||
94 | |||
95 | /** |
||
96 | * @param $indent |
||
97 | * @param $text |
||
98 | * @return mixed |
||
99 | */ |
||
100 | private function addAsterisksForEachLine($indent, $text) |
||
104 | |||
105 | /** |
||
106 | * @param DocBlock $docblock |
||
107 | * @param $wrapLength |
||
108 | * @return string |
||
109 | */ |
||
110 | 4 | private function getSummaryAndDescriptionTextBlock(DocBlock $docblock, $wrapLength) |
|
120 | |||
121 | /** |
||
122 | * @param DocBlock $docblock |
||
123 | * @param $wrapLength |
||
124 | * @param $indent |
||
125 | * @param $comment |
||
126 | * @return string |
||
127 | */ |
||
128 | 4 | private function addTagBlock(DocBlock $docblock, $wrapLength, $indent, $comment) |
|
143 | } |
||
144 |