Completed
Push — prototype ( 3bfdd7...aec713 )
by Peter
07:47
created

Console::green()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 3
nc 1
nop 1
dl 0
loc 5
rs 9.4285
c 0
b 0
f 0
1
<?php
2
/**
3
 * Webino (http://webino.sk)
4
 *
5
 * @link        https://github.com/webino for the canonical source repository
6
 * @copyright   Copyright (c) 2015-2017 Webino, s.r.o. (http://webino.sk)
7
 * @author      Peter Bačinský <[email protected]>
8
 * @license     BSD-3-Clause
9
 */
10
11
namespace WebinoAppLib\Service;
12
13
use League\CLImate\CLImate;
14
use League\CLImate\TerminalObject\Dynamic;
15
16
/**
17
 * Class Console
18
 */
19
class Console
20
{
21
    /**
22
     * @var CLImate
23
     */
24
    protected $engine;
25
26
    /**
27
     * @param CLImate $engine
28
     */
29
    public function __construct(CLImate $engine)
30
    {
31
        $this->engine = $engine;
32
    }
33
34
    /**
35
     * Add literal art directory
36
     *
37
     * @param string $dir
38
     * @return $this
39
     */
40
    public function addArt($dir)
41
    {
42
        $this->engine->addArt($dir);
43
        return $this;
44
    }
45
46
    /**
47
     * Clear screen
48
     *
49
     * @return $this
50
     */
51
    public function clear()
52
    {
53
        $this->engine->clear();
54
        return $this;
55
    }
56
57
    /**
58
     * Black text color
59
     *
60
     * @param string|null $str
61
     * @return $this
62
     */
63
    public function black($str = null)
64
    {
65
        $this->engine->black($str);
66
        return $this;
67
    }
68
69
    /**
70
     * Red text color
71
     *
72
     * @param string|null $str
73
     * @return $this
74
     */
75
    public function red($str = null)
76
    {
77
        $this->engine->red($str);
78
        return $this;
79
    }
80
81
    /**
82
     * Green text color
83
     *
84
     * @param string|null $str
85
     * @return $this
86
     */
87
    public function green($str = null)
88
    {
89
        $this->engine->green($str);
90
        return $this;
91
    }
92
93
    /**
94
     * Yellow text color
95
     *
96
     * @param string|null $str
97
     * @return $this
98
     */
99
    public function yellow($str = null)
100
    {
101
        $this->engine->yellow($str);
102
        return $this;
103
    }
104
105
    /**
106
     * Blue text color
107
     *
108
     * @param string|null $str
109
     * @return $this
110
     */
111
    public function blue($str = null)
112
    {
113
        $this->engine->blue($str);
114
        return $this;
115
    }
116
117
    /**
118
     * Magenta text color
119
     *
120
     * @param string|null $str
121
     * @return $this
122
     */
123
    public function magenta($str = null)
124
    {
125
        $this->engine->magenta($str);
126
        return $this;
127
    }
128
129
    /**
130
     * Cyan text color
131
     *
132
     * @param string|null $str
133
     * @return $this
134
     */
135
    public function cyan($str = null)
136
    {
137
        $this->engine->cyan($str);
138
        return $this;
139
    }
140
141
    /**
142
     * Light gray text color
143
     *
144
     * @param string|null $str
145
     * @return $this
146
     */
147
    public function lightGray($str = null)
148
    {
149
        $this->engine->lightGray($str);
150
        return $this;
151
    }
152
153
    /**
154
     * Dark gray text color
155
     *
156
     * @param string|null $str
157
     * @return $this
158
     */
159
    public function darkGray($str = null)
160
    {
161
        $this->engine->darkGray($str);
162
        return $this;
163
    }
164
165
    /**
166
     * Light red text color
167
     *
168
     * @param string|null $str
169
     * @return $this
170
     */
171
    public function lightRed($str = null)
172
    {
173
        $this->engine->lightRed($str);
174
        return $this;
175
    }
176
177
    /**
178
     * Light green text color
179
     *
180
     * @param string|null $str
181
     * @return $this
182
     */
183
    public function lightGreen($str = null)
184
    {
185
        $this->engine->lightGreen($str);
186
        return $this;
187
    }
188
189
    /**
190
     * Light yellow text color
191
     *
192
     * @param string|null $str
193
     * @return $this
194
     */
195
    public function lightYellow($str = null)
196
    {
197
        $this->engine->lightYellow($str);
198
        return $this;
199
    }
200
201
    /**
202
     * Light blue text color
203
     *
204
     * @param string|null $str
205
     * @return $this
206
     */
207
    public function lightBlue($str = null)
208
    {
209
        $this->engine->lightBlue($str);
210
        return $this;
211
    }
212
213
    /**
214
     * Light magenta text color
215
     *
216
     * @param string|null $str
217
     * @return $this
218
     */
219
    public function lightMagenta($str = null)
220
    {
221
        $this->engine->lightMagenta($str);
222
        return $this;
223
    }
224
225
    /**
226
     * Light cyan text color
227
     *
228
     * @param string|null $str
229
     * @return $this
230
     */
231
    public function lightCyan($str = null)
232
    {
233
        $this->engine->lightCyan($str);
234
        return $this;
235
    }
236
237
    /**
238
     * White text color
239
     *
240
     * @param string|null $str
241
     * @return $this
242
     */
243
    public function white($str = null)
244
    {
245
        $this->engine->white($str);
246
        return $this;
247
    }
248
249
    /**
250
     * Black background color
251
     *
252
     * @param string|null $str
253
     * @return $this
254
     */
255
    public function blackBg($str = null)
256
    {
257
        $this->engine->backgroundBlack($str);
258
        return $this;
259
    }
260
261
    /**
262
     * Red background color
263
     *
264
     * @param string|null $str
265
     * @return $this
266
     */
267
    public function redBg($str = null)
268
    {
269
        $this->engine->backgroundRed($str);
270
        return $this;
271
    }
272
273
    /**
274
     * Green background color
275
     *
276
     * @param string|null $str
277
     * @return $this
278
     */
279
    public function greenBg($str = null)
280
    {
281
        $this->engine->backgroundGreen($str);
282
        return $this;
283
    }
284
285
    /**
286
     * Yellow background color
287
     *
288
     * @param string|null $str
289
     * @return $this
290
     */
291
    public function yellowBg($str = null)
292
    {
293
        $this->engine->backgroundYellow($str);
294
        return $this;
295
    }
296
297
    /**
298
     * Blue background color
299
     *
300
     * @param string|null $str
301
     * @return $this
302
     */
303
    public function blueBg($str = null)
304
    {
305
        $this->engine->backgroundBlue($str);
306
        return $this;
307
    }
308
309
    /**
310
     * Magenta background color
311
     *
312
     * @param string|null $str
313
     * @return $this
314
     */
315
    public function magentaBg($str = null)
316
    {
317
        $this->engine->backgroundMagenta($str);
318
        return $this;
319
    }
320
321
    /**
322
     * Cyan background color
323
     *
324
     * @param string|null $str
325
     * @return $this
326
     */
327
    public function cyanBg($str = null)
328
    {
329
        $this->engine->backgroundCyan($str);
330
        return $this;
331
    }
332
333
    /**
334
     * Light gray background color
335
     *
336
     * @param string|null $str
337
     * @return $this
338
     */
339
    public function lightGrayBg($str = null)
340
    {
341
        $this->engine->backgroundLightGray($str);
342
        return $this;
343
    }
344
345
    /**
346
     * Dark gray background color
347
     *
348
     * @param string|null $str
349
     * @return $this
350
     */
351
    public function darkGrayBg($str = null)
352
    {
353
        $this->engine->backgroundDarkGray($str);
354
        return $this;
355
    }
356
357
    /**
358
     * Light red background color
359
     *
360
     * @param string|null $str
361
     * @return $this
362
     */
363
    public function lightRedBg($str = null)
364
    {
365
        $this->engine->backgroundLightRed($str);
366
        return $this;
367
    }
368
369
    /**
370
     * Light green background color
371
     *
372
     * @param string|null $str
373
     * @return $this
374
     */
375
    public function lightGreenBg($str = null)
376
    {
377
        $this->engine->backgroundLightGreen($str);
378
        return $this;
379
    }
380
381
    /**
382
     * Light yellow background color
383
     *
384
     * @param string|null $str
385
     * @return $this
386
     */
387
    public function lightYellowBg($str = null)
388
    {
389
        $this->engine->backgroundLightYellow($str);
390
        return $this;
391
    }
392
393
    /**
394
     * Light blue background color
395
     *
396
     * @param string|null $str
397
     * @return $this
398
     */
399
    public function lightBlueBg($str = null)
400
    {
401
        $this->engine->backgroundLightBlue($str);
402
        return $this;
403
    }
404
405
    /**
406
     * Light magenta background color
407
     *
408
     * @param string|null $str
409
     * @return $this
410
     */
411
    public function lightMagentaBg($str = null)
412
    {
413
        $this->engine->backgroundLightMagenta($str);
414
        return $this;
415
    }
416
417
    /**
418
     * Light cyan background color
419
     *
420
     * @param string|null $str
421
     * @return $this
422
     */
423
    public function lightCyanBg($str = null)
424
    {
425
        $this->engine->backgroundLightCyan($str);
426
        return $this;
427
    }
428
429
    /**
430
     * White background color
431
     *
432
     * @param string|null $str
433
     * @return $this
434
     */
435
    public function whiteBg($str = null)
436
    {
437
        $this->engine->backgroundWhite($str);
438
        return $this;
439
    }
440
441
    /**
442
     * Bold text
443
     *
444
     * @param string|null $str
445
     * @return $this
446
     */
447
    public function bold($str = null)
448
    {
449
        $this->engine->bold($str);
450
        return $this;
451
    }
452
453
    /**
454
     * Dimmed text
455
     *
456
     * @param string|null $str
457
     * @return $this
458
     */
459
    public function dim($str = null)
460
    {
461
        $this->engine->dim($str);
462
        return $this;
463
    }
464
465
    /**
466
     * Underlined text
467
     *
468
     * @param string|null $str
469
     * @return $this
470
     */
471
    public function underline($str = null)
472
    {
473
        $this->engine->underline($str);
474
        return $this;
475
    }
476
477
    /**
478
     * Blinking text
479
     *
480
     * @param string|null $str
481
     * @return $this
482
     */
483
    public function blink($str = null)
484
    {
485
        $this->engine->blink($str);
486
        return $this;
487
    }
488
489
    /**
490
     * Inverted text
491
     *
492
     * @param string|null $str
493
     * @return $this
494
     */
495
    public function invert($str = null)
496
    {
497
        $this->engine->invert($str);
498
        return $this;
499
    }
500
501
    /**
502
     * Hidden text
503
     *
504
     * @param string|null $str
505
     * @return $this
506
     */
507
    public function hidden($str = null)
508
    {
509
        $this->engine->hidden($str);
510
        return $this;
511
    }
512
513
    /**
514
     * Info text
515
     *
516
     * @param string|null $str
517
     * @return $this
518
     */
519
    public function info($str = null)
520
    {
521
        $this->engine->info($str);
522
        return $this;
523
    }
524
525
    /**
526
     * Comment text
527
     *
528
     * @param string|null $str
529
     * @return $this
530
     */
531
    public function comment($str = null)
532
    {
533
        $this->engine->comment($str);
534
        return $this;
535
    }
536
537
    /**
538
     * Whispered text
539
     *
540
     * @param string|null $str
541
     * @return $this
542
     */
543
    public function whisper($str = null)
544
    {
545
        $this->engine->whisper($str);
546
        return $this;
547
    }
548
549
    /**
550
     * Shouted text
551
     *
552
     * @param string|null $str
553
     * @return $this
554
     */
555
    public function shout($str = null)
556
    {
557
        $this->engine->shout($str);
558
        return $this;
559
    }
560
561
    /**
562
     * Error text
563
     *
564
     * @param string|null $str
565
     * @return $this
566
     */
567
    public function error($str = null)
568
    {
569
        $this->engine->error($str);
570
        return $this;
571
    }
572
573
    /**
574
     * Data columns
575
     *
576
     * @param array $data
577
     * @param int|null $columnCount
578
     * @return $this
579
     */
580
    public function columns(array $data, $columnCount = null)
581
    {
582
        $this->engine->columns($data, $columnCount);
583
        return $this;
584
    }
585
586
    /**
587
     * Text output
588
     *
589
     * @param string $str
590
     * @return $this
591
     */
592
    public function out($str)
593
    {
594
        $this->engine->out($str);
595
        return $this;
596
    }
597
598
    /**
599
     * Inline text output
600
     *
601
     * @param string $str
602
     * @return $this
603
     */
604
    public function inline($str)
605
    {
606
        $this->engine->inline($str);
607
        return $this;
608
    }
609
610
    /**
611
     * Data table
612
     *
613
     * @param array $data
614
     * @return $this
615
     */
616
    public function table(array $data)
617
    {
618
        $this->engine->table($data);
619
        return $this;
620
    }
621
622
    /**
623
     * JSON data
624
     *
625
     * @param mixed $var
626
     * @return $this
627
     */
628
    public function json($var)
629
    {
630
        $this->engine->json($var);
631
        return $this;
632
    }
633
634
    /**
635
     * Space
636
     *
637
     * @param int $count
638
     * @return $this
639
     */
640
    public function sp($count = 1)
641
    {
642
        for ($i=0; $i < $count; $i++) {
643
            $this->engine->inline(' ');
644
        }
645
        return $this;
646
    }
647
648
    /**
649
     * New line
650
     *
651
     * @param int $count
652
     * @return $this
653
     */
654
    public function br($count = 1)
655
    {
656
        $this->engine->br($count);
657
        return $this;
658
    }
659
660
    /**
661
     * Tabulator
662
     *
663
     * @param int $count
664
     * @return $this
665
     */
666
    public function tab($count = 1)
667
    {
668
        $this->engine->tab($count);
669
        return $this;
670
    }
671
672
    /**
673
     * Draw art
674
     *
675
     * @param string $art
676
     * @return $this
677
     */
678
    public function draw($art)
679
    {
680
        $this->engine->draw($art);
681
        return $this;
682
    }
683
684
    /**
685
     * Literal border
686
     *
687
     * @param string|null $char
688
     * @param int|null $length
689
     * @return $this
690
     */
691
    public function border($char = null, $length = null)
692
    {
693
        $this->engine->border($char, $length);
694
        return $this;
695
    }
696
697
    /**
698
     * Variable debug
699
     *
700
     * @param mixed $var
701
     * @return $this
702
     */
703
    public function dump($var)
704
    {
705
        $this->engine->dump($var);
706
        return $this;
707
    }
708
709
    /**
710
     * Literal strong text
711
     *
712
     * @param string $output
713
     * @param string|null $char
714
     * @param int|null $length
715
     * @return $this
716
     */
717
    public function flank($output, $char = null, $length = null)
718
    {
719
        $this->engine->flank($output, $char, $length);
720
        return $this;
721
    }
722
723
    /**
724
     * Progress bar
725
     *
726
     * @param int|null $total
727
     * @return Dynamic\Progress
728
     */
729
    public function progress($total = null)
730
    {
731
        return $this->engine->progress($total);
732
    }
733
734
    /**
735
     * Left literal padding
736
     *
737
     * @param int $length
738
     * @param string $char
739
     * @return Dynamic\Padding
740
     */
741
    public function padding($length = 0, $char = '.')
742
    {
743
        return $this->engine->padding($length, $char);
744
    }
745
746
    /**
747
     * Optional input text
748
     *
749
     * @param string $prompt
750
     * @return Dynamic\Input
751
     */
752
    public function input($prompt)
753
    {
754
        return $this->engine->input($prompt);
755
    }
756
757
    /**
758
     * Confirmation input text
759
     *
760
     * @param string $prompt
761
     * @return Dynamic\Confirm
762
     */
763
    public function confirm($prompt)
764
    {
765
        return $this->engine->confirm($prompt);
766
    }
767
768
    /**
769
     * Password input text
770
     *
771
     * @param string $prompt
772
     * @return Dynamic\Password
773
     */
774
    public function password($prompt)
775
    {
776
        return $this->engine->password($prompt);
777
    }
778
779
    /**
780
     * Multi-option input text
781
     *
782
     * @param string $prompt
783
     * @param array $options
784
     * @return Dynamic\Checkboxes
785
     */
786
    public function checkboxes($prompt, array $options)
787
    {
788
        return $this->engine->checkboxes($prompt, $options);
789
    }
790
791
    /**
792
     * Single-option input text
793
     *
794
     * @param string $prompt
795
     * @param array $options
796
     * @return Dynamic\Radio
797
     */
798
    public function radio($prompt, array $options)
799
    {
800
        return $this->engine->radio($prompt, $options);
801
    }
802
803
    /**
804
     * Play an animation
805
     *
806
     * @param string $art
807
     * @return Dynamic\Animation
808
     */
809
    public function animation($art)
810
    {
811
        return $this->engine->animation($art);
812
    }
813
}
814