-
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathusing_themes_class.php
53 lines (48 loc) · 1.8 KB
/
using_themes_class.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
<?php declare(strict_types=1);
require_once __DIR__ . '/../vendor/autoload.php';
require_once __DIR__ . '/__helper_functions.php';
use AlecRabbit\ConsoleColour\Contracts\BG;
use AlecRabbit\ConsoleColour\Contracts\Color;
use AlecRabbit\ConsoleColour\Contracts\Effect;
use AlecRabbit\ConsoleColour\Contracts\Styles;
use AlecRabbit\ConsoleColour\Themes;
/**
* @method fire(string $text)
* @method lagoon(string $text)
* @method blink(string $text)
* @method alert(string $text)
*/
class MyThemes extends Themes
{
// These strings are used as methods names
public const FIRE = 'fire';
public const LAGOON = 'lagoon';
public const BLINK = 'blink';
public const ALERT = 'alert';
public const MY_STYLES = [
// name => [styles],
self::FIRE => [Color::LIGHT_RED, Effect::BOLD, BG::LIGHT_YELLOW, Effect::ITALIC],
self::LAGOON => [Color::BLACK, BG::LIGHT_BLUE, Effect::UNDERLINE],
self::BLINK => [Effect::BLINK, Color::LIGHT_CYAN],
// You can use interface `Styles` to define your theme
self::ALERT => [Styles::BLINK, Styles::WHITE, Styles::BG_LIGHT_RED],
];
/**
* @return array
*/
protected function prepareThemes(): array
{
return \array_merge(self::MY_STYLES, parent::prepareThemes());
}
}
$base = new Themes(, null);
$my = new MyThemes(, null);
echoText($base->red('This text is red.'));
echoText($base->comment('This is comment.'));
echoText($base->underlinedBold('This text is underlined and bold.'));
echoText($my->green('This text is green.')); // Method defined in Themes class
echoText($my->blink('This text is light cyan and blinking.'));
echoText($my->lagoon('This is "lagoon" text.'));
echoText($my->fire('This is "fire" text.'));
echoText($my->error('This is "error" text.'));
echoText($my->alert('This is "alert" text.'));