1313 *
1414 * PHP version 7.2 or greater
1515 *
16- * @package jblond\Diff\Renderer\Text
17- * @author Ferry Cools <[email protected] > 16+ * @package jblond\Diff\Renderer\Text
17+ * @author Ferry Cools <[email protected] > 1818 * @copyright (c) 2020 Ferry Cools
19- * @license New BSD License http://www.opensource.org/licenses/bsd-license.php
20- * @version 2.2.1
21- * @link https://github.com/JBlond/php-diff
19+ * @license New BSD License http://www.opensource.org/licenses/bsd-license.php
20+ * @version 2.2.1
21+ * @link https://github.com/JBlond/php-diff
2222 */
2323class InlineCli extends MainRenderer implements SubRendererInterface
2424{
@@ -31,7 +31,7 @@ class InlineCli extends MainRenderer implements SubRendererInterface
3131 /**
3232 * InlineCli constructor.
3333 *
34- * @param array $options Custom defined options for the inline diff renderer.
34+ * @param array $options Custom defined options for the inline diff renderer.
3535 *
3636 * @see Inline::$subOptions
3737 */
@@ -67,7 +67,7 @@ public function generateDiffHeader(): string
6767 /**
6868 * Generate a string representation of the start of a block.
6969 *
70- * @param array $changes Contains the op-codes about the changes between two blocks of lines.
70+ * @param array $changes Contains the op-codes about the changes between two blocks of lines.
7171 *
7272 * @return string Start of the diff view.
7373 */
@@ -89,14 +89,17 @@ public function generateSkippedLines(): string
8989 /**
9090 * Generate a string representation lines without differences between the two versions.
9191 *
92- * @param array $changes Contains the op-codes about the changes between two blocks of lines.
92+ * @param array $changes Contains the op-codes about the changes between two blocks of lines.
9393 *
9494 * @return string Text with no difference.
9595 */
9696 public function generateLinesEqual (array $ changes ): string
9797 {
9898 $ returnValue = '' ;
99- $ padding = str_repeat (' ' , $ this ->maxLineMarkerWidth - strlen ($ this ->options ['equalityMarkers ' ][0 ]));
99+ $ padding = str_repeat (
100+ ' ' ,
101+ max ($ this ->maxLineMarkerWidth - strlen ($ this ->options ['equalityMarkers ' ][0 ]), 0 )
102+ );
100103
101104 foreach ($ changes ['base ' ]['lines ' ] as $ line ) {
102105 $ returnValue .= $ this ->options ['equalityMarkers ' ][0 ] . $ padding . '| ' . $ line . "\n" ;
@@ -108,15 +111,18 @@ public function generateLinesEqual(array $changes): string
108111 /**
109112 * Generate a string representation of lines that are added to the 2nd version.
110113 *
111- * @param array $changes Contains the op-codes about the changes between two blocks of text.
114+ * @param array $changes Contains the op-codes about the changes between two blocks of text.
112115 *
113116 * @return string Added text.
114117 */
115118 public function generateLinesInsert (array $ changes ): string
116119 {
117120 $ colorize = new CliColors ();
118121 $ returnValue = '' ;
119- $ padding = str_repeat (' ' , $ this ->maxLineMarkerWidth - strlen ($ this ->options ['insertMarkers ' ][0 ]));
122+ $ padding = str_repeat (
123+ ' ' ,
124+ max ($ this ->maxLineMarkerWidth - strlen ($ this ->options ['insertMarkers ' ][0 ]), 0 )
125+ );
120126
121127 foreach ($ changes ['changed ' ]['lines ' ] as $ line ) {
122128 if ($ this ->options ['cliColor ' ]) {
@@ -132,15 +138,18 @@ public function generateLinesInsert(array $changes): string
132138 /**
133139 * Generate a string representation of lines that are removed from the 2nd version.
134140 *
135- * @param array $changes Contains the op-codes about the changes between two blocks of text.
141+ * @param array $changes Contains the op-codes about the changes between two blocks of text.
136142 *
137143 * @return string Removed text.
138144 */
139145 public function generateLinesDelete (array $ changes ): string
140146 {
141147 $ colorize = new CliColors ();
142148 $ returnValue = '' ;
143- $ padding = str_repeat (' ' , $ this ->maxLineMarkerWidth - strlen ($ this ->options ['deleteMarkers ' ][0 ]));
149+ $ padding = str_repeat (
150+ ' ' ,
151+ max ($ this ->maxLineMarkerWidth - strlen ($ this ->options ['deleteMarkers ' ][0 ]), 0 )
152+ );
144153
145154 foreach ($ changes ['base ' ]['lines ' ] as $ line ) {
146155 if ($ this ->options ['cliColor ' ]) {
@@ -156,7 +165,7 @@ public function generateLinesDelete(array $changes): string
156165 /**
157166 * Generate a string representation of lines that are partially modified.
158167 *
159- * @param array $changes Contains the op-codes about the changes between two blocks of text.
168+ * @param array $changes Contains the op-codes about the changes between two blocks of text.
160169 *
161170 * @return string Modified text.
162171 */
@@ -179,10 +188,10 @@ public function generateLinesReplace(array $changes): string
179188 /**
180189 * Merge the changes between two lines together and mark these changes.
181190 *
182- * @param array $baseLines Lines of version 1.
183- * @param array $changedLines Lines of version 2.
184- * @param array|null[] $deleteColors Fore- and background colors of part that is removed from the 2nd version.
185- * @param array|null[] $insertColors Fore- and background colors of part that is added to the 2nd version.
191+ * @param array $baseLines Lines of version 1.
192+ * @param array $changedLines Lines of version 2.
193+ * @param array|null[] $deleteColors Fore- and background colors of part that is removed from the 2nd version.
194+ * @param array|null[] $insertColors Fore- and background colors of part that is added to the 2nd version.
186195 *
187196 * Option $deleteColors and $insertColors only have affect when this class's cliColors option is set to true.
188197 *
@@ -194,7 +203,11 @@ private function mergeChanges(
194203 array $ deleteColors = [null , null ],
195204 array $ insertColors = [null , null ]
196205 ): array {
197- $ padding = str_repeat (' ' , $ this ->maxLineMarkerWidth - strlen ($ this ->options ['equalityMarkers ' ][1 ]));
206+ $ padding = str_repeat (
207+ ' ' ,
208+ max ($ this ->maxLineMarkerWidth - strlen ($ this ->options ['equalityMarkers ' ][1 ]), 0 )
209+ );
210+
198211 if ($ this ->options ['cliColor ' ]) {
199212 $ colorize = new CliColors ();
200213 }
@@ -233,7 +246,7 @@ private function mergeChanges(
233246 /**
234247 * Generate a string representation of the end of a block.
235248 *
236- * @param array $changes Contains the op-codes about the changes between two blocks of text.
249+ * @param array $changes Contains the op-codes about the changes between two blocks of text.
237250 *
238251 * @return string End of the block
239252 */
0 commit comments