Windows   A
last analyzed

Complexity

Total Complexity 1

Size/Duplication

Total Lines 55
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 1
eloc 40
c 1
b 0
f 0
dl 0
loc 55
ccs 37
cts 37
cp 1
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A setTags() 0 49 1
1
<?php
2
3
namespace kalanis\kw_clipr\Output;
4
5
6
/**
7
 * Class Windows
8
 * @package kalanis\kw_clipr\Output
9
 * Available since Windows 10
10
 * The base is similar to Posix, but has different stronger color coding
11
 * @link https://docs.microsoft.com/en-us/windows/console/console-virtual-terminal-sequences
12
 * @link https://www.codeproject.com/Tips/5255355/How-to-Put-Color-on-Windows-console
13
 * @link https://stackoverflow.com/questions/2048509/how-to-echo-with-different-colors-in-the-windows-command-line
14
 */
15
class Windows extends AOutput
16
{
17
    protected string $closeSequence = "\e[0m";
18
    protected string $formatBackSequence = "\e[%dD";
19
    protected string $eolSequence = "\r\n";
20
21 15
    protected function setTags(): void
22
    {
23 15
        parent::setTags();
24
        # format style
25 15
        $this->addTranslation('normal', "\e[0m");
26 15
        $this->addTranslation('bold', "\e[1m");
27 15
        $this->addTranslation('under', "\e[4m");
28
29
        # default ones
30
        # foreground colors
31 15
        $this->addTranslation('black', "\e[30m");
32 15
        $this->addTranslation('red', "\e[31m");
33 15
        $this->addTranslation('green', "\e[32m");
34 15
        $this->addTranslation('brown', "\e[33m");
35 15
        $this->addTranslation('blue', "\e[34m");
36 15
        $this->addTranslation('purple', "\e[35m");
37 15
        $this->addTranslation('cyan', "\e[36m");
38 15
        $this->addTranslation('gray', "\e[37m");
39
40
        # background colors
41 15
        $this->addTranslation('blackbg', "\e[40m");
42 15
        $this->addTranslation('redbg', "\e[41m");
43 15
        $this->addTranslation('greenbg', "\e[42m");
44 15
        $this->addTranslation('brownbg', "\e[43m");
45 15
        $this->addTranslation('bluebg', "\e[44m");
46 15
        $this->addTranslation('purplebg', "\e[45m");
47 15
        $this->addTranslation('cyanbg', "\e[46m");
48 15
        $this->addTranslation('graybg', "\e[47m");
49
50
        # stronger ones
51
        # foreground colors
52 15
        $this->addTranslation('dgray', "\e[90m");
53 15
        $this->addTranslation('lred', "\e[91m");
54 15
        $this->addTranslation('lgreen', "\e[92m");
55 15
        $this->addTranslation('yellow', "\e[93m");
56 15
        $this->addTranslation('lblue', "\e[94m");
57 15
        $this->addTranslation('magenta', "\e[95m");
58 15
        $this->addTranslation('lcyan', "\e[96m");
59 15
        $this->addTranslation('white', "\e[97m");
60
61
        # background colors
62 15
        $this->addTranslation('dgraybg', "\e[100m");
63 15
        $this->addTranslation('lredbg', "\e[101m");
64 15
        $this->addTranslation('lgreenbg', "\e[102m");
65 15
        $this->addTranslation('yellowbg', "\e[103m");
66 15
        $this->addTranslation('lbluebg', "\e[104m");
67 15
        $this->addTranslation('magentabg', "\e[105m");
68 15
        $this->addTranslation('lcyanbg', "\e[106m");
69 15
        $this->addTranslation('whitebg', "\e[107m");
70 15
    }
71
}
72