PhpColor   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 40
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 4
eloc 9
c 1
b 0
f 0
dl 0
loc 40
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A instance() 0 7 2
A getColorInstance() 0 3 1
A __construct() 0 6 1
1
<?php
2
/**
3
 * PHP命令行颜色
4
 *
5
 * 目前多层标签嵌套还存在问题,当多层嵌套时,内嵌标签后面的文字样式会丢失,可暂时使用<reset>标签恢复,待原作者修正
6
 *
7
 * @author mybsdc <[email protected]>
8
 * @date 2019/11/29
9
 * @time 10:52
10
 */
11
12
namespace Luolongfei\Lib;
13
14
use Colors\Color;
15
16
class PhpColor
17
{
18
    /**
19
     * @var PhpColor
20
     */
21
    protected static $instance;
22
23
    /**
24
     * @var Color
25
     */
26
    protected $colorInstance;
27
28
    public function __construct()
29
    {
30
        $this->colorInstance = new Color();
31
32
        // Create my own style
33
        $this->colorInstance->setUserStyles([
34
//                '自定义标签' => 'red',
35
        ]);
36
    }
37
38
    /**
39
     * @return PhpColor
40
     */
41
    public static function instance()
42
    {
43
        if (!self::$instance instanceof self) {
0 ignored issues
show
introduced by
self::instance is always a sub-type of self.
Loading history...
44
            self::$instance = new self();
45
        }
46
47
        return self::$instance;
48
    }
49
50
    /**
51
     * @return Color
52
     */
53
    public function getColorInstance()
54
    {
55
        return $this->colorInstance;
56
    }
57
}