Issues (10)

src/Output/Writer.php (1 issue)

Labels
Severity
1
<?php
2
3
/**
4
 * Platine Console
5
 *
6
 * Platine Console is a powerful library with support of custom
7
 * style to build command line interface applications
8
 *
9
 * This content is released under the MIT License (MIT)
10
 *
11
 * Copyright (c) 2020 Platine Console
12
 * Copyright (c) 2017-2020 Jitendra Adhikari
13
 *
14
 * Permission is hereby granted, free of charge, to any person obtaining a copy
15
 * of this software and associated documentation files (the "Software"), to deal
16
 * in the Software without restriction, including without limitation the rights
17
 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
18
 * copies of the Software, and to permit persons to whom the Software is
19
 * furnished to do so, subject to the following conditions:
20
 *
21
 * The above copyright notice and this permission notice shall be included in all
22
 * copies or substantial portions of the Software.
23
 *
24
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
25
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
26
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
27
 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
28
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
29
 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
30
 * SOFTWARE.
31
 */
32
33
/**
34
 *  @file Writer.php
35
 *
36
 *  The Output Writer class
37
 *
38
 *  @package    Platine\Console\Output
39
 *  @author Platine Developers Team
40
 *  @copyright  Copyright (c) 2020
41
 *  @license    http://opensource.org/licenses/MIT  MIT License
42
 *  @link   https://www.platine-php.com
43
 *  @version 1.0.0
44
 *  @filesource
45
 */
46
47
declare(strict_types=1);
48
49
namespace Platine\Console\Output;
50
51
use Platine\Console\Exception\RuntimeException;
52
53
/**
54
 * @class Writer
55
 * @package Platine\Console\Output
56
 *
57
 * @method Writer bold(string $text, bool $eol = false)
58
 * @method Writer dim(string $text, bool $eol = false)
59
 * @method Writer italic(string $text, bool $eol = false)
60
 * @method Writer underline(string $text, bool $eol = false)
61
 * @method Writer black(string $text, bool $eol = false)
62
 * @method Writer red(string $text, bool $eol = false)
63
 * @method Writer green(string $text, bool $eol = false)
64
 * @method Writer yellow(string $text, bool $eol = false)
65
 * @method Writer blue(string $text, bool $eol = false)
66
 * @method Writer purple(string $text, bool $eol = false)
67
 * @method Writer cyan(string $text, bool $eol = false)
68
 * @method Writer white(string $text, bool $eol = false)
69
 * @method Writer gray(string $text, bool $eol = false)
70
 * @method Writer darkgray(string $text, bool $eol = false)
71
 * @method Writer bgBlack(string $text, bool $eol = false)
72
 * @method Writer bgRed(string $text, bool $eol = false)
73
 * @method Writer bgGreen(string $text, bool $eol = false)
74
 * @method Writer bgYellow(string $text, bool $eol = false)
75
 * @method Writer bgBlue(string $text, bool $eol = false)
76
 * @method Writer bgPurple(string $text, bool $eol = false)
77
 * @method Writer bgCyan(string $text, bool $eol = false)
78
 * @method Writer bgWhite(string $text, bool $eol = false)
79
 * @method Writer bgGray(string $text, bool $eol = false)
80
 * @method Writer bgDarkgray(string $text, bool $eol = false)
81
 * @method Writer boldBlack(string $text, bool $eol = false)
82
 * @method Writer boldRed(string $text, bool $eol = false)
83
 * @method Writer boldGreen(string $text, bool $eol = false)
84
 * @method Writer boldYellow(string $text, bool $eol = false)
85
 * @method Writer boldBlue(string $text, bool $eol = false)
86
 * @method Writer boldPurple(string $text, bool $eol = false)
87
 * @method Writer boldCyan(string $text, bool $eol = false)
88
 * @method Writer boldWhite(string $text, bool $eol = false)
89
 * @method Writer boldGray(string $text, bool $eol = false)
90
 * @method Writer boldDarkgray(string $text, bool $eol = false)
91
 * @method Writer dimBlack(string $text, bool $eol = false)
92
 * @method Writer dimRed(string $text, bool $eol = false)
93
 * @method Writer dimGreen(string $text, bool $eol = false)
94
 * @method Writer dimYellow(string $text, bool $eol = false)
95
 * @method Writer dimBlue(string $text, bool $eol = false)
96
 * @method Writer dimPurple(string $text, bool $eol = false)
97
 * @method Writer dimCyan(string $text, bool $eol = false)
98
 * @method Writer dimWhite(string $text, bool $eol = false)
99
 * @method Writer dimGray(string $text, bool $eol = false)
100
 * @method Writer dimDarkgray(string $text, bool $eol = false)
101
 * @method Writer italicBlack(string $text, bool $eol = false)
102
 * @method Writer italicRed(string $text, bool $eol = false)
103
 * @method Writer italicGreen(string $text, bool $eol = false)
104
 * @method Writer italicYellow(string $text, bool $eol = false)
105
 * @method Writer italicBlue(string $text, bool $eol = false)
106
 * @method Writer italicPurple(string $text, bool $eol = false)
107
 * @method Writer italicCyan(string $text, bool $eol = false)
108
 * @method Writer italicWhite(string $text, bool $eol = false)
109
 * @method Writer italicGray(string $text, bool $eol = false)
110
 * @method Writer italicDarkgray(string $text, bool $eol = false)
111
 * @method Writer underlineBlack(string $text, bool $eol = false)
112
 * @method Writer underlineRed(string $text, bool $eol = false)
113
 * @method Writer underlineGreen(string $text, bool $eol = false)
114
 * @method Writer underlineYellow(string $text, bool $eol = false)
115
 * @method Writer underlineBlue(string $text, bool $eol = false)
116
 * @method Writer underlinePurple(string $text, bool $eol = false)
117
 * @method Writer underlineCyan(string $text, bool $eol = false)
118
 * @method Writer underlineWhite(string $text, bool $eol = false)
119
 * @method Writer underlineGray(string $text, bool $eol = false)
120
 * @method Writer underlineDarkgray(string $text, bool $eol = false)
121
 * @method Writer boldBgBlack(string $text, bool $eol = false)
122
 * @method Writer boldBgRed(string $text, bool $eol = false)
123
 * @method Writer boldBgGreen(string $text, bool $eol = false)
124
 * @method Writer boldBgYellow(string $text, bool $eol = false)
125
 * @method Writer boldBgBlue(string $text, bool $eol = false)
126
 * @method Writer boldBgPurple(string $text, bool $eol = false)
127
 * @method Writer boldBgCyan(string $text, bool $eol = false)
128
 * @method Writer boldBgWhite(string $text, bool $eol = false)
129
 * @method Writer boldBgGray(string $text, bool $eol = false)
130
 * @method Writer boldBgDarkgray(string $text, bool $eol = false)
131
 * @method Writer dimBgBlack(string $text, bool $eol = false)
132
 * @method Writer dimBgRed(string $text, bool $eol = false)
133
 * @method Writer dimBgGreen(string $text, bool $eol = false)
134
 * @method Writer dimBgYellow(string $text, bool $eol = false)
135
 * @method Writer dimBgBlue(string $text, bool $eol = false)
136
 * @method Writer dimBgPurple(string $text, bool $eol = false)
137
 * @method Writer dimBgCyan(string $text, bool $eol = false)
138
 * @method Writer dimBgWhite(string $text, bool $eol = false)
139
 * @method Writer dimBgGray(string $text, bool $eol = false)
140
 * @method Writer dimBgDarkgray(string $text, bool $eol = false)
141
 * @method Writer italicBgBlack(string $text, bool $eol = false)
142
 * @method Writer italicBgRed(string $text, bool $eol = false)
143
 * @method Writer italicBgGreen(string $text, bool $eol = false)
144
 * @method Writer italicBgYellow(string $text, bool $eol = false)
145
 * @method Writer italicBgBlue(string $text, bool $eol = false)
146
 * @method Writer italicBgPurple(string $text, bool $eol = false)
147
 * @method Writer italicBgCyan(string $text, bool $eol = false)
148
 * @method Writer italicBgWhite(string $text, bool $eol = false)
149
 * @method Writer italicBgGray(string $text, bool $eol = false)
150
 * @method Writer italicBgDarkgray(string $text, bool $eol = false)
151
 * @method Writer underlineBgBlack(string $text, bool $eol = false)
152
 * @method Writer underlineBgRed(string $text, bool $eol = false)
153
 * @method Writer underlineBgGreen(string $text, bool $eol = false)
154
 * @method Writer underlineBgYellow(string $text, bool $eol = false)
155
 * @method Writer underlineBgBlue(string $text, bool $eol = false)
156
 * @method Writer underlineBgPurple(string $text, bool $eol = false)
157
 * @method Writer underlineBgCyan(string $text, bool $eol = false)
158
 * @method Writer underlineBgWhite(string $text, bool $eol = false)
159
 * @method Writer underlineBgGray(string $text, bool $eol = false)
160
 * @method Writer underlineBgDarkgray(string $text, bool $eol = false)
161
 * @method Writer boldBlackBgRed(string $text, bool $eol = false)
162
 * @method Writer boldBlackBgGreen(string $text, bool $eol = false)
163
 * @method Writer boldBlackBgYellow(string $text, bool $eol = false)
164
 * @method Writer boldBlackBgBlue(string $text, bool $eol = false)
165
 * @method Writer boldBlackBgPurple(string $text, bool $eol = false)
166
 * @method Writer boldBlackBgCyan(string $text, bool $eol = false)
167
 * @method Writer boldBlackBgWhite(string $text, bool $eol = false)
168
 * @method Writer boldBlackBgGray(string $text, bool $eol = false)
169
 * @method Writer boldBlackBgDarkgray(string $text, bool $eol = false)
170
 * @method Writer boldRedBgBlack(string $text, bool $eol = false)
171
 * @method Writer boldRedBgGreen(string $text, bool $eol = false)
172
 * @method Writer boldRedBgYellow(string $text, bool $eol = false)
173
 * @method Writer boldRedBgBlue(string $text, bool $eol = false)
174
 * @method Writer boldRedBgPurple(string $text, bool $eol = false)
175
 * @method Writer boldRedBgCyan(string $text, bool $eol = false)
176
 * @method Writer boldRedBgWhite(string $text, bool $eol = false)
177
 * @method Writer boldRedBgGray(string $text, bool $eol = false)
178
 * @method Writer boldRedBgDarkgray(string $text, bool $eol = false)
179
 * @method Writer boldGreenBgBlack(string $text, bool $eol = false)
180
 * @method Writer boldGreenBgRed(string $text, bool $eol = false)
181
 * @method Writer boldGreenBgYellow(string $text, bool $eol = false)
182
 * @method Writer boldGreenBgBlue(string $text, bool $eol = false)
183
 * @method Writer boldGreenBgPurple(string $text, bool $eol = false)
184
 * @method Writer boldGreenBgCyan(string $text, bool $eol = false)
185
 * @method Writer boldGreenBgWhite(string $text, bool $eol = false)
186
 * @method Writer boldGreenBgGray(string $text, bool $eol = false)
187
 * @method Writer boldGreenBgDarkgray(string $text, bool $eol = false)
188
 * @method Writer boldYellowBgBlack(string $text, bool $eol = false)
189
 * @method Writer boldYellowBgRed(string $text, bool $eol = false)
190
 * @method Writer boldYellowBgGreen(string $text, bool $eol = false)
191
 * @method Writer boldYellowBgBlue(string $text, bool $eol = false)
192
 * @method Writer boldYellowBgPurple(string $text, bool $eol = false)
193
 * @method Writer boldYellowBgCyan(string $text, bool $eol = false)
194
 * @method Writer boldYellowBgWhite(string $text, bool $eol = false)
195
 * @method Writer boldYellowBgGray(string $text, bool $eol = false)
196
 * @method Writer boldYellowBgDarkgray(string $text, bool $eol = false)
197
 * @method Writer boldBlueBgBlack(string $text, bool $eol = false)
198
 * @method Writer boldBlueBgRed(string $text, bool $eol = false)
199
 * @method Writer boldBlueBgGreen(string $text, bool $eol = false)
200
 * @method Writer boldBlueBgYellow(string $text, bool $eol = false)
201
 * @method Writer boldBlueBgPurple(string $text, bool $eol = false)
202
 * @method Writer boldBlueBgCyan(string $text, bool $eol = false)
203
 * @method Writer boldBlueBgWhite(string $text, bool $eol = false)
204
 * @method Writer boldBlueBgGray(string $text, bool $eol = false)
205
 * @method Writer boldBlueBgDarkgray(string $text, bool $eol = false)
206
 * @method Writer boldPurpleBgBlack(string $text, bool $eol = false)
207
 * @method Writer boldPurpleBgRed(string $text, bool $eol = false)
208
 * @method Writer boldPurpleBgGreen(string $text, bool $eol = false)
209
 * @method Writer boldPurpleBgYellow(string $text, bool $eol = false)
210
 * @method Writer boldPurpleBgBlue(string $text, bool $eol = false)
211
 * @method Writer boldPurpleBgCyan(string $text, bool $eol = false)
212
 * @method Writer boldPurpleBgWhite(string $text, bool $eol = false)
213
 * @method Writer boldPurpleBgGray(string $text, bool $eol = false)
214
 * @method Writer boldPurpleBgDarkgray(string $text, bool $eol = false)
215
 * @method Writer boldCyanBgBlack(string $text, bool $eol = false)
216
 * @method Writer boldCyanBgRed(string $text, bool $eol = false)
217
 * @method Writer boldCyanBgGreen(string $text, bool $eol = false)
218
 * @method Writer boldCyanBgYellow(string $text, bool $eol = false)
219
 * @method Writer boldCyanBgBlue(string $text, bool $eol = false)
220
 * @method Writer boldCyanBgPurple(string $text, bool $eol = false)
221
 * @method Writer boldCyanBgWhite(string $text, bool $eol = false)
222
 * @method Writer boldCyanBgGray(string $text, bool $eol = false)
223
 * @method Writer boldCyanBgDarkgray(string $text, bool $eol = false)
224
 * @method Writer boldWhiteBgBlack(string $text, bool $eol = false)
225
 * @method Writer boldWhiteBgRed(string $text, bool $eol = false)
226
 * @method Writer boldWhiteBgGreen(string $text, bool $eol = false)
227
 * @method Writer boldWhiteBgYellow(string $text, bool $eol = false)
228
 * @method Writer boldWhiteBgBlue(string $text, bool $eol = false)
229
 * @method Writer boldWhiteBgPurple(string $text, bool $eol = false)
230
 * @method Writer boldWhiteBgCyan(string $text, bool $eol = false)
231
 * @method Writer boldWhiteBgGray(string $text, bool $eol = false)
232
 * @method Writer boldWhiteBgDarkgray(string $text, bool $eol = false)
233
 * @method Writer boldGrayBgBlack(string $text, bool $eol = false)
234
 * @method Writer boldGrayBgRed(string $text, bool $eol = false)
235
 * @method Writer boldGrayBgGreen(string $text, bool $eol = false)
236
 * @method Writer boldGrayBgYellow(string $text, bool $eol = false)
237
 * @method Writer boldGrayBgBlue(string $text, bool $eol = false)
238
 * @method Writer boldGrayBgPurple(string $text, bool $eol = false)
239
 * @method Writer boldGrayBgCyan(string $text, bool $eol = false)
240
 * @method Writer boldGrayBgWhite(string $text, bool $eol = false)
241
 * @method Writer boldGrayBgDarkgray(string $text, bool $eol = false)
242
 * @method Writer boldDarkgrayBgBlack(string $text, bool $eol = false)
243
 * @method Writer boldDarkgrayBgRed(string $text, bool $eol = false)
244
 * @method Writer boldDarkgrayBgGreen(string $text, bool $eol = false)
245
 * @method Writer boldDarkgrayBgYellow(string $text, bool $eol = false)
246
 * @method Writer boldDarkgrayBgBlue(string $text, bool $eol = false)
247
 * @method Writer boldDarkgrayBgPurple(string $text, bool $eol = false)
248
 * @method Writer boldDarkgrayBgCyan(string $text, bool $eol = false)
249
 * @method Writer boldDarkgrayBgWhite(string $text, bool $eol = false)
250
 * @method Writer boldDarkgrayBgGray(string $text, bool $eol = false)
251
 * @method Writer dimBlackBgRed(string $text, bool $eol = false)
252
 * @method Writer dimBlackBgGreen(string $text, bool $eol = false)
253
 * @method Writer dimBlackBgYellow(string $text, bool $eol = false)
254
 * @method Writer dimBlackBgBlue(string $text, bool $eol = false)
255
 * @method Writer dimBlackBgPurple(string $text, bool $eol = false)
256
 * @method Writer dimBlackBgCyan(string $text, bool $eol = false)
257
 * @method Writer dimBlackBgWhite(string $text, bool $eol = false)
258
 * @method Writer dimBlackBgGray(string $text, bool $eol = false)
259
 * @method Writer dimBlackBgDarkgray(string $text, bool $eol = false)
260
 * @method Writer dimRedBgBlack(string $text, bool $eol = false)
261
 * @method Writer dimRedBgGreen(string $text, bool $eol = false)
262
 * @method Writer dimRedBgYellow(string $text, bool $eol = false)
263
 * @method Writer dimRedBgBlue(string $text, bool $eol = false)
264
 * @method Writer dimRedBgPurple(string $text, bool $eol = false)
265
 * @method Writer dimRedBgCyan(string $text, bool $eol = false)
266
 * @method Writer dimRedBgWhite(string $text, bool $eol = false)
267
 * @method Writer dimRedBgGray(string $text, bool $eol = false)
268
 * @method Writer dimRedBgDarkgray(string $text, bool $eol = false)
269
 * @method Writer dimGreenBgBlack(string $text, bool $eol = false)
270
 * @method Writer dimGreenBgRed(string $text, bool $eol = false)
271
 * @method Writer dimGreenBgYellow(string $text, bool $eol = false)
272
 * @method Writer dimGreenBgBlue(string $text, bool $eol = false)
273
 * @method Writer dimGreenBgPurple(string $text, bool $eol = false)
274
 * @method Writer dimGreenBgCyan(string $text, bool $eol = false)
275
 * @method Writer dimGreenBgWhite(string $text, bool $eol = false)
276
 * @method Writer dimGreenBgGray(string $text, bool $eol = false)
277
 * @method Writer dimGreenBgDarkgray(string $text, bool $eol = false)
278
 * @method Writer dimYellowBgBlack(string $text, bool $eol = false)
279
 * @method Writer dimYellowBgRed(string $text, bool $eol = false)
280
 * @method Writer dimYellowBgGreen(string $text, bool $eol = false)
281
 * @method Writer dimYellowBgBlue(string $text, bool $eol = false)
282
 * @method Writer dimYellowBgPurple(string $text, bool $eol = false)
283
 * @method Writer dimYellowBgCyan(string $text, bool $eol = false)
284
 * @method Writer dimYellowBgWhite(string $text, bool $eol = false)
285
 * @method Writer dimYellowBgGray(string $text, bool $eol = false)
286
 * @method Writer dimYellowBgDarkgray(string $text, bool $eol = false)
287
 * @method Writer dimBlueBgBlack(string $text, bool $eol = false)
288
 * @method Writer dimBlueBgRed(string $text, bool $eol = false)
289
 * @method Writer dimBlueBgGreen(string $text, bool $eol = false)
290
 * @method Writer dimBlueBgYellow(string $text, bool $eol = false)
291
 * @method Writer dimBlueBgPurple(string $text, bool $eol = false)
292
 * @method Writer dimBlueBgCyan(string $text, bool $eol = false)
293
 * @method Writer dimBlueBgWhite(string $text, bool $eol = false)
294
 * @method Writer dimBlueBgGray(string $text, bool $eol = false)
295
 * @method Writer dimBlueBgDarkgray(string $text, bool $eol = false)
296
 * @method Writer dimPurpleBgBlack(string $text, bool $eol = false)
297
 * @method Writer dimPurpleBgRed(string $text, bool $eol = false)
298
 * @method Writer dimPurpleBgGreen(string $text, bool $eol = false)
299
 * @method Writer dimPurpleBgYellow(string $text, bool $eol = false)
300
 * @method Writer dimPurpleBgBlue(string $text, bool $eol = false)
301
 * @method Writer dimPurpleBgCyan(string $text, bool $eol = false)
302
 * @method Writer dimPurpleBgWhite(string $text, bool $eol = false)
303
 * @method Writer dimPurpleBgGray(string $text, bool $eol = false)
304
 * @method Writer dimPurpleBgDarkgray(string $text, bool $eol = false)
305
 * @method Writer dimCyanBgBlack(string $text, bool $eol = false)
306
 * @method Writer dimCyanBgRed(string $text, bool $eol = false)
307
 * @method Writer dimCyanBgGreen(string $text, bool $eol = false)
308
 * @method Writer dimCyanBgYellow(string $text, bool $eol = false)
309
 * @method Writer dimCyanBgBlue(string $text, bool $eol = false)
310
 * @method Writer dimCyanBgPurple(string $text, bool $eol = false)
311
 * @method Writer dimCyanBgWhite(string $text, bool $eol = false)
312
 * @method Writer dimCyanBgGray(string $text, bool $eol = false)
313
 * @method Writer dimCyanBgDarkgray(string $text, bool $eol = false)
314
 * @method Writer dimWhiteBgBlack(string $text, bool $eol = false)
315
 * @method Writer dimWhiteBgRed(string $text, bool $eol = false)
316
 * @method Writer dimWhiteBgGreen(string $text, bool $eol = false)
317
 * @method Writer dimWhiteBgYellow(string $text, bool $eol = false)
318
 * @method Writer dimWhiteBgBlue(string $text, bool $eol = false)
319
 * @method Writer dimWhiteBgPurple(string $text, bool $eol = false)
320
 * @method Writer dimWhiteBgCyan(string $text, bool $eol = false)
321
 * @method Writer dimWhiteBgGray(string $text, bool $eol = false)
322
 * @method Writer dimWhiteBgDarkgray(string $text, bool $eol = false)
323
 * @method Writer dimGrayBgBlack(string $text, bool $eol = false)
324
 * @method Writer dimGrayBgRed(string $text, bool $eol = false)
325
 * @method Writer dimGrayBgGreen(string $text, bool $eol = false)
326
 * @method Writer dimGrayBgYellow(string $text, bool $eol = false)
327
 * @method Writer dimGrayBgBlue(string $text, bool $eol = false)
328
 * @method Writer dimGrayBgPurple(string $text, bool $eol = false)
329
 * @method Writer dimGrayBgCyan(string $text, bool $eol = false)
330
 * @method Writer dimGrayBgWhite(string $text, bool $eol = false)
331
 * @method Writer dimGrayBgDarkgray(string $text, bool $eol = false)
332
 * @method Writer dimDarkgrayBgBlack(string $text, bool $eol = false)
333
 * @method Writer dimDarkgrayBgRed(string $text, bool $eol = false)
334
 * @method Writer dimDarkgrayBgGreen(string $text, bool $eol = false)
335
 * @method Writer dimDarkgrayBgYellow(string $text, bool $eol = false)
336
 * @method Writer dimDarkgrayBgBlue(string $text, bool $eol = false)
337
 * @method Writer dimDarkgrayBgPurple(string $text, bool $eol = false)
338
 * @method Writer dimDarkgrayBgCyan(string $text, bool $eol = false)
339
 * @method Writer dimDarkgrayBgWhite(string $text, bool $eol = false)
340
 * @method Writer dimDarkgrayBgGray(string $text, bool $eol = false)
341
 * @method Writer italicBlackBgRed(string $text, bool $eol = false)
342
 * @method Writer italicBlackBgGreen(string $text, bool $eol = false)
343
 * @method Writer italicBlackBgYellow(string $text, bool $eol = false)
344
 * @method Writer italicBlackBgBlue(string $text, bool $eol = false)
345
 * @method Writer italicBlackBgPurple(string $text, bool $eol = false)
346
 * @method Writer italicBlackBgCyan(string $text, bool $eol = false)
347
 * @method Writer italicBlackBgWhite(string $text, bool $eol = false)
348
 * @method Writer italicBlackBgGray(string $text, bool $eol = false)
349
 * @method Writer italicBlackBgDarkgray(string $text, bool $eol = false)
350
 * @method Writer italicRedBgBlack(string $text, bool $eol = false)
351
 * @method Writer italicRedBgGreen(string $text, bool $eol = false)
352
 * @method Writer italicRedBgYellow(string $text, bool $eol = false)
353
 * @method Writer italicRedBgBlue(string $text, bool $eol = false)
354
 * @method Writer italicRedBgPurple(string $text, bool $eol = false)
355
 * @method Writer italicRedBgCyan(string $text, bool $eol = false)
356
 * @method Writer italicRedBgWhite(string $text, bool $eol = false)
357
 * @method Writer italicRedBgGray(string $text, bool $eol = false)
358
 * @method Writer italicRedBgDarkgray(string $text, bool $eol = false)
359
 * @method Writer italicGreenBgBlack(string $text, bool $eol = false)
360
 * @method Writer italicGreenBgRed(string $text, bool $eol = false)
361
 * @method Writer italicGreenBgYellow(string $text, bool $eol = false)
362
 * @method Writer italicGreenBgBlue(string $text, bool $eol = false)
363
 * @method Writer italicGreenBgPurple(string $text, bool $eol = false)
364
 * @method Writer italicGreenBgCyan(string $text, bool $eol = false)
365
 * @method Writer italicGreenBgWhite(string $text, bool $eol = false)
366
 * @method Writer italicGreenBgGray(string $text, bool $eol = false)
367
 * @method Writer italicGreenBgDarkgray(string $text, bool $eol = false)
368
 * @method Writer italicYellowBgBlack(string $text, bool $eol = false)
369
 * @method Writer italicYellowBgRed(string $text, bool $eol = false)
370
 * @method Writer italicYellowBgGreen(string $text, bool $eol = false)
371
 * @method Writer italicYellowBgBlue(string $text, bool $eol = false)
372
 * @method Writer italicYellowBgPurple(string $text, bool $eol = false)
373
 * @method Writer italicYellowBgCyan(string $text, bool $eol = false)
374
 * @method Writer italicYellowBgWhite(string $text, bool $eol = false)
375
 * @method Writer italicYellowBgGray(string $text, bool $eol = false)
376
 * @method Writer italicYellowBgDarkgray(string $text, bool $eol = false)
377
 * @method Writer italicBlueBgBlack(string $text, bool $eol = false)
378
 * @method Writer italicBlueBgRed(string $text, bool $eol = false)
379
 * @method Writer italicBlueBgGreen(string $text, bool $eol = false)
380
 * @method Writer italicBlueBgYellow(string $text, bool $eol = false)
381
 * @method Writer italicBlueBgPurple(string $text, bool $eol = false)
382
 * @method Writer italicBlueBgCyan(string $text, bool $eol = false)
383
 * @method Writer italicBlueBgWhite(string $text, bool $eol = false)
384
 * @method Writer italicBlueBgGray(string $text, bool $eol = false)
385
 * @method Writer italicBlueBgDarkgray(string $text, bool $eol = false)
386
 * @method Writer italicPurpleBgBlack(string $text, bool $eol = false)
387
 * @method Writer italicPurpleBgRed(string $text, bool $eol = false)
388
 * @method Writer italicPurpleBgGreen(string $text, bool $eol = false)
389
 * @method Writer italicPurpleBgYellow(string $text, bool $eol = false)
390
 * @method Writer italicPurpleBgBlue(string $text, bool $eol = false)
391
 * @method Writer italicPurpleBgCyan(string $text, bool $eol = false)
392
 * @method Writer italicPurpleBgWhite(string $text, bool $eol = false)
393
 * @method Writer italicPurpleBgGray(string $text, bool $eol = false)
394
 * @method Writer italicPurpleBgDarkgray(string $text, bool $eol = false)
395
 * @method Writer italicCyanBgBlack(string $text, bool $eol = false)
396
 * @method Writer italicCyanBgRed(string $text, bool $eol = false)
397
 * @method Writer italicCyanBgGreen(string $text, bool $eol = false)
398
 * @method Writer italicCyanBgYellow(string $text, bool $eol = false)
399
 * @method Writer italicCyanBgBlue(string $text, bool $eol = false)
400
 * @method Writer italicCyanBgPurple(string $text, bool $eol = false)
401
 * @method Writer italicCyanBgWhite(string $text, bool $eol = false)
402
 * @method Writer italicCyanBgGray(string $text, bool $eol = false)
403
 * @method Writer italicCyanBgDarkgray(string $text, bool $eol = false)
404
 * @method Writer italicWhiteBgBlack(string $text, bool $eol = false)
405
 * @method Writer italicWhiteBgRed(string $text, bool $eol = false)
406
 * @method Writer italicWhiteBgGreen(string $text, bool $eol = false)
407
 * @method Writer italicWhiteBgYellow(string $text, bool $eol = false)
408
 * @method Writer italicWhiteBgBlue(string $text, bool $eol = false)
409
 * @method Writer italicWhiteBgPurple(string $text, bool $eol = false)
410
 * @method Writer italicWhiteBgCyan(string $text, bool $eol = false)
411
 * @method Writer italicWhiteBgGray(string $text, bool $eol = false)
412
 * @method Writer italicWhiteBgDarkgray(string $text, bool $eol = false)
413
 * @method Writer italicGrayBgBlack(string $text, bool $eol = false)
414
 * @method Writer italicGrayBgRed(string $text, bool $eol = false)
415
 * @method Writer italicGrayBgGreen(string $text, bool $eol = false)
416
 * @method Writer italicGrayBgYellow(string $text, bool $eol = false)
417
 * @method Writer italicGrayBgBlue(string $text, bool $eol = false)
418
 * @method Writer italicGrayBgPurple(string $text, bool $eol = false)
419
 * @method Writer italicGrayBgCyan(string $text, bool $eol = false)
420
 * @method Writer italicGrayBgWhite(string $text, bool $eol = false)
421
 * @method Writer italicGrayBgDarkgray(string $text, bool $eol = false)
422
 * @method Writer italicDarkgrayBgBlack(string $text, bool $eol = false)
423
 * @method Writer italicDarkgrayBgRed(string $text, bool $eol = false)
424
 * @method Writer italicDarkgrayBgGreen(string $text, bool $eol = false)
425
 * @method Writer italicDarkgrayBgYellow(string $text, bool $eol = false)
426
 * @method Writer italicDarkgrayBgBlue(string $text, bool $eol = false)
427
 * @method Writer italicDarkgrayBgPurple(string $text, bool $eol = false)
428
 * @method Writer italicDarkgrayBgCyan(string $text, bool $eol = false)
429
 * @method Writer italicDarkgrayBgWhite(string $text, bool $eol = false)
430
 * @method Writer italicDarkgrayBgGray(string $text, bool $eol = false)
431
 * @method Writer underlineBlackBgRed(string $text, bool $eol = false)
432
 * @method Writer underlineBlackBgGreen(string $text, bool $eol = false)
433
 * @method Writer underlineBlackBgYellow(string $text, bool $eol = false)
434
 * @method Writer underlineBlackBgBlue(string $text, bool $eol = false)
435
 * @method Writer underlineBlackBgPurple(string $text, bool $eol = false)
436
 * @method Writer underlineBlackBgCyan(string $text, bool $eol = false)
437
 * @method Writer underlineBlackBgWhite(string $text, bool $eol = false)
438
 * @method Writer underlineBlackBgGray(string $text, bool $eol = false)
439
 * @method Writer underlineBlackBgDarkgray(string $text, bool $eol = false)
440
 * @method Writer underlineRedBgBlack(string $text, bool $eol = false)
441
 * @method Writer underlineRedBgGreen(string $text, bool $eol = false)
442
 * @method Writer underlineRedBgYellow(string $text, bool $eol = false)
443
 * @method Writer underlineRedBgBlue(string $text, bool $eol = false)
444
 * @method Writer underlineRedBgPurple(string $text, bool $eol = false)
445
 * @method Writer underlineRedBgCyan(string $text, bool $eol = false)
446
 * @method Writer underlineRedBgWhite(string $text, bool $eol = false)
447
 * @method Writer underlineRedBgGray(string $text, bool $eol = false)
448
 * @method Writer underlineRedBgDarkgray(string $text, bool $eol = false)
449
 * @method Writer underlineGreenBgBlack(string $text, bool $eol = false)
450
 * @method Writer underlineGreenBgRed(string $text, bool $eol = false)
451
 * @method Writer underlineGreenBgYellow(string $text, bool $eol = false)
452
 * @method Writer underlineGreenBgBlue(string $text, bool $eol = false)
453
 * @method Writer underlineGreenBgPurple(string $text, bool $eol = false)
454
 * @method Writer underlineGreenBgCyan(string $text, bool $eol = false)
455
 * @method Writer underlineGreenBgWhite(string $text, bool $eol = false)
456
 * @method Writer underlineGreenBgGray(string $text, bool $eol = false)
457
 * @method Writer underlineGreenBgDarkgray(string $text, bool $eol = false)
458
 * @method Writer underlineYellowBgBlack(string $text, bool $eol = false)
459
 * @method Writer underlineYellowBgRed(string $text, bool $eol = false)
460
 * @method Writer underlineYellowBgGreen(string $text, bool $eol = false)
461
 * @method Writer underlineYellowBgBlue(string $text, bool $eol = false)
462
 * @method Writer underlineYellowBgPurple(string $text, bool $eol = false)
463
 * @method Writer underlineYellowBgCyan(string $text, bool $eol = false)
464
 * @method Writer underlineYellowBgWhite(string $text, bool $eol = false)
465
 * @method Writer underlineYellowBgGray(string $text, bool $eol = false)
466
 * @method Writer underlineYellowBgDarkgray(string $text, bool $eol = false)
467
 * @method Writer underlineBlueBgBlack(string $text, bool $eol = false)
468
 * @method Writer underlineBlueBgRed(string $text, bool $eol = false)
469
 * @method Writer underlineBlueBgGreen(string $text, bool $eol = false)
470
 * @method Writer underlineBlueBgYellow(string $text, bool $eol = false)
471
 * @method Writer underlineBlueBgPurple(string $text, bool $eol = false)
472
 * @method Writer underlineBlueBgCyan(string $text, bool $eol = false)
473
 * @method Writer underlineBlueBgWhite(string $text, bool $eol = false)
474
 * @method Writer underlineBlueBgGray(string $text, bool $eol = false)
475
 * @method Writer underlineBlueBgDarkgray(string $text, bool $eol = false)
476
 * @method Writer underlinePurpleBgBlack(string $text, bool $eol = false)
477
 * @method Writer underlinePurpleBgRed(string $text, bool $eol = false)
478
 * @method Writer underlinePurpleBgGreen(string $text, bool $eol = false)
479
 * @method Writer underlinePurpleBgYellow(string $text, bool $eol = false)
480
 * @method Writer underlinePurpleBgBlue(string $text, bool $eol = false)
481
 * @method Writer underlinePurpleBgCyan(string $text, bool $eol = false)
482
 * @method Writer underlinePurpleBgWhite(string $text, bool $eol = false)
483
 * @method Writer underlinePurpleBgGray(string $text, bool $eol = false)
484
 * @method Writer underlinePurpleBgDarkgray(string $text, bool $eol = false)
485
 * @method Writer underlineCyanBgBlack(string $text, bool $eol = false)
486
 * @method Writer underlineCyanBgRed(string $text, bool $eol = false)
487
 * @method Writer underlineCyanBgGreen(string $text, bool $eol = false)
488
 * @method Writer underlineCyanBgYellow(string $text, bool $eol = false)
489
 * @method Writer underlineCyanBgBlue(string $text, bool $eol = false)
490
 * @method Writer underlineCyanBgPurple(string $text, bool $eol = false)
491
 * @method Writer underlineCyanBgWhite(string $text, bool $eol = false)
492
 * @method Writer underlineCyanBgGray(string $text, bool $eol = false)
493
 * @method Writer underlineCyanBgDarkgray(string $text, bool $eol = false)
494
 * @method Writer underlineWhiteBgBlack(string $text, bool $eol = false)
495
 * @method Writer underlineWhiteBgRed(string $text, bool $eol = false)
496
 * @method Writer underlineWhiteBgGreen(string $text, bool $eol = false)
497
 * @method Writer underlineWhiteBgYellow(string $text, bool $eol = false)
498
 * @method Writer underlineWhiteBgBlue(string $text, bool $eol = false)
499
 * @method Writer underlineWhiteBgPurple(string $text, bool $eol = false)
500
 * @method Writer underlineWhiteBgCyan(string $text, bool $eol = false)
501
 * @method Writer underlineWhiteBgGray(string $text, bool $eol = false)
502
 * @method Writer underlineWhiteBgDarkgray(string $text, bool $eol = false)
503
 * @method Writer underlineGrayBgBlack(string $text, bool $eol = false)
504
 * @method Writer underlineGrayBgRed(string $text, bool $eol = false)
505
 * @method Writer underlineGrayBgGreen(string $text, bool $eol = false)
506
 * @method Writer underlineGrayBgYellow(string $text, bool $eol = false)
507
 * @method Writer underlineGrayBgBlue(string $text, bool $eol = false)
508
 * @method Writer underlineGrayBgPurple(string $text, bool $eol = false)
509
 * @method Writer underlineGrayBgCyan(string $text, bool $eol = false)
510
 * @method Writer underlineGrayBgWhite(string $text, bool $eol = false)
511
 * @method Writer underlineGrayBgDarkgray(string $text, bool $eol = false)
512
 * @method Writer underlineDarkgrayBgBlack(string $text, bool $eol = false)
513
 * @method Writer underlineDarkgrayBgRed(string $text, bool $eol = false)
514
 * @method Writer underlineDarkgrayBgGreen(string $text, bool $eol = false)
515
 * @method Writer underlineDarkgrayBgYellow(string $text, bool $eol = false)
516
 * @method Writer underlineDarkgrayBgBlue(string $text, bool $eol = false)
517
 * @method Writer underlineDarkgrayBgPurple(string $text, bool $eol = false)
518
 * @method Writer underlineDarkgrayBgCyan(string $text, bool $eol = false)
519
 * @method Writer underlineDarkgrayBgWhite(string $text, bool $eol = false)
520
 * @method Writer underlineDarkgrayBgGray(string $text, bool $eol = false)
521
 * @method Writer blackBgRed(string $text, bool $eol = false)
522
 * @method Writer blackBgGreen(string $text, bool $eol = false)
523
 * @method Writer blackBgYellow(string $text, bool $eol = false)
524
 * @method Writer blackBgBlue(string $text, bool $eol = false)
525
 * @method Writer blackBgPurple(string $text, bool $eol = false)
526
 * @method Writer blackBgCyan(string $text, bool $eol = false)
527
 * @method Writer blackBgWhite(string $text, bool $eol = false)
528
 * @method Writer blackBgGray(string $text, bool $eol = false)
529
 * @method Writer blackBgDarkgray(string $text, bool $eol = false)
530
 * @method Writer redBgBlack(string $text, bool $eol = false)
531
 * @method Writer redBgGreen(string $text, bool $eol = false)
532
 * @method Writer redBgYellow(string $text, bool $eol = false)
533
 * @method Writer redBgBlue(string $text, bool $eol = false)
534
 * @method Writer redBgPurple(string $text, bool $eol = false)
535
 * @method Writer redBgCyan(string $text, bool $eol = false)
536
 * @method Writer redBgWhite(string $text, bool $eol = false)
537
 * @method Writer redBgGray(string $text, bool $eol = false)
538
 * @method Writer redBgDarkgray(string $text, bool $eol = false)
539
 * @method Writer greenBgBlack(string $text, bool $eol = false)
540
 * @method Writer greenBgRed(string $text, bool $eol = false)
541
 * @method Writer greenBgYellow(string $text, bool $eol = false)
542
 * @method Writer greenBgBlue(string $text, bool $eol = false)
543
 * @method Writer greenBgPurple(string $text, bool $eol = false)
544
 * @method Writer greenBgCyan(string $text, bool $eol = false)
545
 * @method Writer greenBgWhite(string $text, bool $eol = false)
546
 * @method Writer greenBgGray(string $text, bool $eol = false)
547
 * @method Writer greenBgDarkgray(string $text, bool $eol = false)
548
 * @method Writer yellowBgBlack(string $text, bool $eol = false)
549
 * @method Writer yellowBgRed(string $text, bool $eol = false)
550
 * @method Writer yellowBgGreen(string $text, bool $eol = false)
551
 * @method Writer yellowBgBlue(string $text, bool $eol = false)
552
 * @method Writer yellowBgPurple(string $text, bool $eol = false)
553
 * @method Writer yellowBgCyan(string $text, bool $eol = false)
554
 * @method Writer yellowBgWhite(string $text, bool $eol = false)
555
 * @method Writer yellowBgGray(string $text, bool $eol = false)
556
 * @method Writer yellowBgDarkgray(string $text, bool $eol = false)
557
 * @method Writer blueBgBlack(string $text, bool $eol = false)
558
 * @method Writer blueBgRed(string $text, bool $eol = false)
559
 * @method Writer blueBgGreen(string $text, bool $eol = false)
560
 * @method Writer blueBgYellow(string $text, bool $eol = false)
561
 * @method Writer blueBgPurple(string $text, bool $eol = false)
562
 * @method Writer blueBgCyan(string $text, bool $eol = false)
563
 * @method Writer blueBgWhite(string $text, bool $eol = false)
564
 * @method Writer blueBgGray(string $text, bool $eol = false)
565
 * @method Writer blueBgDarkgray(string $text, bool $eol = false)
566
 * @method Writer purpleBgBlack(string $text, bool $eol = false)
567
 * @method Writer purpleBgRed(string $text, bool $eol = false)
568
 * @method Writer purpleBgGreen(string $text, bool $eol = false)
569
 * @method Writer purpleBgYellow(string $text, bool $eol = false)
570
 * @method Writer purpleBgBlue(string $text, bool $eol = false)
571
 * @method Writer purpleBgCyan(string $text, bool $eol = false)
572
 * @method Writer purpleBgWhite(string $text, bool $eol = false)
573
 * @method Writer purpleBgGray(string $text, bool $eol = false)
574
 * @method Writer purpleBgDarkgray(string $text, bool $eol = false)
575
 * @method Writer cyanBgBlack(string $text, bool $eol = false)
576
 * @method Writer cyanBgRed(string $text, bool $eol = false)
577
 * @method Writer cyanBgGreen(string $text, bool $eol = false)
578
 * @method Writer cyanBgYellow(string $text, bool $eol = false)
579
 * @method Writer cyanBgBlue(string $text, bool $eol = false)
580
 * @method Writer cyanBgPurple(string $text, bool $eol = false)
581
 * @method Writer cyanBgWhite(string $text, bool $eol = false)
582
 * @method Writer cyanBgGray(string $text, bool $eol = false)
583
 * @method Writer cyanBgDarkgray(string $text, bool $eol = false)
584
 * @method Writer whiteBgBlack(string $text, bool $eol = false)
585
 * @method Writer whiteBgRed(string $text, bool $eol = false)
586
 * @method Writer whiteBgGreen(string $text, bool $eol = false)
587
 * @method Writer whiteBgYellow(string $text, bool $eol = false)
588
 * @method Writer whiteBgBlue(string $text, bool $eol = false)
589
 * @method Writer whiteBgPurple(string $text, bool $eol = false)
590
 * @method Writer whiteBgCyan(string $text, bool $eol = false)
591
 * @method Writer whiteBgGray(string $text, bool $eol = false)
592
 * @method Writer whiteBgDarkgray(string $text, bool $eol = false)
593
 * @method Writer grayBgBlack(string $text, bool $eol = false)
594
 * @method Writer grayBgRed(string $text, bool $eol = false)
595
 * @method Writer grayBgGreen(string $text, bool $eol = false)
596
 * @method Writer grayBgYellow(string $text, bool $eol = false)
597
 * @method Writer grayBgBlue(string $text, bool $eol = false)
598
 * @method Writer grayBgPurple(string $text, bool $eol = false)
599
 * @method Writer grayBgCyan(string $text, bool $eol = false)
600
 * @method Writer grayBgWhite(string $text, bool $eol = false)
601
 * @method Writer grayBgDarkgray(string $text, bool $eol = false)
602
 * @method Writer darkgrayBgBlack(string $text, bool $eol = false)
603
 * @method Writer darkgrayBgRed(string $text, bool $eol = false)
604
 * @method Writer darkgrayBgGreen(string $text, bool $eol = false)
605
 * @method Writer darkgrayBgYellow(string $text, bool $eol = false)
606
 * @method Writer darkgrayBgBlue(string $text, bool $eol = false)
607
 * @method Writer darkgrayBgPurple(string $text, bool $eol = false)
608
 * @method Writer darkgrayBgCyan(string $text, bool $eol = false)
609
 * @method Writer darkgrayBgWhite(string $text, bool $eol = false)
610
 * @method Writer darkgrayBgGray(string $text, bool $eol = false)
611
 */
612
class Writer
613
{
614
    /**
615
     * The output stream
616
     * @var resource
617
     */
618
    protected $stream;
619
620
    /**
621
     * The output error stream
622
     * @var resource
623
     */
624
    protected $errorStream;
625
626
    /**
627
     * Color method to be called
628
     * @var string
629
     */
630
    protected string $method = '';
631
632
    /**
633
     * The color instance
634
     * @var Color
635
     */
636
    protected Color $color;
637
638
    /**
639
     * The cursor instance
640
     * @var Cursor
641
     */
642
    protected Cursor $cursor;
643
644
    /**
645
     * Create new instance
646
     * @param string|null $path the output write path
647
     * @param Color|null $color the color instance
648
     */
649
    public function __construct(?string $path = null, ?Color $color = null)
650
    {
651
        $stream = null;
652
        if ($path !== null) {
653
            $stream = fopen($path, 'w');
654
655
            if ($stream === false) {
656
                throw new RuntimeException(sprintf(
657
                    'Can not open stream using path [%s]',
658
                    $path
659
                ));
660
            }
661
        }
662
663
        $this->stream = $stream ?? STDOUT;
664
        $this->errorStream = $stream ?? STDERR;
665
666
        $this->color = $color ?? new Color();
667
        $this->cursor = new Cursor();
668
    }
669
670
    /**
671
     * Set the stream
672
     * @param resource $stream
673
     * @return $this
674
     */
675
    public function setStream($stream): self
676
    {
677
        $this->stream = $stream;
678
        return $this;
679
    }
680
681
    /**
682
     * Set the error stream
683
     * @param resource $stream
684
     * @return $this
685
     */
686
    public function setErrorStream($stream): self
687
    {
688
        $this->errorStream = $stream;
689
        return $this;
690
    }
691
692
    /**
693
     * Return the color instance
694
     * @return Color
695
     */
696
    public function getColor(): Color
697
    {
698
        return $this->color;
699
    }
700
701
    /**
702
     * Return the cursor instance
703
     * @return Cursor
704
     */
705
    public function getCursor(): Cursor
706
    {
707
        return $this->cursor;
708
    }
709
710
    /**
711
     * Write the formatted text to standard output.
712
     * @param string $text
713
     * @param bool $eol
714
     * @return $this
715
     */
716
    public function write(string $text, bool $eol = false): self
717
    {
718
        $method = 'line';
719
        if (!empty($this->method)) {
720
            $method = $this->method;
721
            $this->method = '';
722
        }
723
724
        $styledText = $this->color->{$method}($text);
725
        if ($eol) {
726
            $styledText .= PHP_EOL;
727
        }
728
729
        return $this->doWrite($styledText, false);
730
    }
731
732
    /**
733
     * Write the formatted text to standard error.
734
     * @param string $text
735
     * @param bool $eol
736
     * @return $this
737
     */
738
    public function writeError(string $text, bool $eol = false): self
739
    {
740
        $styledText = $this->color->red($text);
741
        if ($eol) {
742
            $styledText .= PHP_EOL;
743
        }
744
745
        return $this->doWrite($styledText, true);
746
    }
747
748
    /**
749
     * Write formatted text in HTML style
750
     * @see Color::colors
751
     *
752
     * @param string $text
753
     * @param bool $eol
754
     * @return $this
755
     */
756
    public function colors(string $text, bool $eol = false): self
757
    {
758
        $styledText = $this->color->colors($text);
759
        if ($eol) {
760
            $styledText .= PHP_EOL;
761
        }
762
763
        return $this->doWrite($styledText, false);
764
    }
765
766
    /**
767
     * Write the raw text to stream.
768
     * @param string $text
769
     * @param bool $error
770
     * @return $this
771
     */
772
    public function raw(string $text, bool $error = false): self
773
    {
774
        return $this->doWrite($text, $error);
775
    }
776
777
    /**
778
     * Generate table for the console
779
     * @param array<int, array<int, array<string, string>>> $rows
780
     * @param array<string, string> $styles
781
     * @return self
782
     */
783
    public function table(array $rows, array $styles = []): self
784
    {
785
        $table = (new Table())->render($rows, $styles);
786
787
        return $this->colors($table, true);
788
    }
789
790
    /**
791
     * Write EOL count times.
792
     * @param int $count
793
     * @return $this
794
     */
795
    public function eol(int $count = 1): self
796
    {
797
        return $this->doWrite(str_repeat(PHP_EOL, max($count, 1)), false);
798
    }
799
800
    /**
801
     * Magic call to handle dynamic color, style
802
     * @param string $method
803
     * @param array<int, mixed> $args
804
     * @return $this|string
805
     */
806
    public function __call(string $method, array $args = []): self|string
807
    {
808
        if (method_exists($this->cursor, $method)) {
809
            return $this->cursor->{$method}(...$args);
810
        }
811
812
        $this->method = $method;
813
814
        return $this->write(...$args);
0 ignored issues
show
$args is expanded, but the parameter $text of Platine\Console\Output\Writer::write() does not expect variable arguments. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

814
        return $this->write(/** @scrutinizer ignore-type */ ...$args);
Loading history...
815
    }
816
817
    /**
818
     * Write to the standard output or standard error stream.
819
     * @param string $text
820
     * @param bool $error
821
     * @return $this
822
     */
823
    protected function doWrite(string $text, bool $error = false): self
824
    {
825
        $stream = $error ?
826
                $this->errorStream
827
                : $this->stream;
828
829
        fwrite($stream, $text);
830
831
        return $this;
832
    }
833
}
834