Completed
Push — master ( 841749...0c8a8c )
by ARCANEDEV
05:30
created

LogStyler   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 86
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
dl 0
loc 86
c 1
b 0
f 0
ccs 11
cts 11
cp 1
rs 10
wmc 5
lcom 1
cbo 1

5 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A get() 0 4 1
A icon() 0 4 1
A color() 0 4 1
A toHighlight() 0 4 1
1
<?php namespace Arcanedev\LogViewer\Utilities;
2
3
use Arcanedev\LogViewer\Contracts\Utilities\LogStyler as LogStylerContract;
4
use Illuminate\Contracts\Config\Repository as ConfigContract;
5
6
/**
7
 * Class     LogStyler
8
 *
9
 * @package  Arcanedev\LogViewer\Utilities
10
 * @author   ARCANEDEV <[email protected]>
11
 */
12
class LogStyler implements LogStylerContract
13
{
14
    /* ------------------------------------------------------------------------------------------------
15
     |  Properties
16
     | ------------------------------------------------------------------------------------------------
17
     */
18
    /**
19
     * The config repository instance.
20
     *
21
     * @var \Illuminate\Contracts\Config\Repository
22
     */
23
    protected $config;
24
25
    /* ------------------------------------------------------------------------------------------------
26
     |  Constructor
27
     | ------------------------------------------------------------------------------------------------
28
     */
29
    /**
30
     * Create a new instance.
31
     *
32
     * @param  \Illuminate\Contracts\Config\Repository  $config
33
     */
34 63
    public function __construct(ConfigContract $config)
35
    {
36 63
        $this->config = $config;
37 63
    }
38
39
    /* ------------------------------------------------------------------------------------------------
40
     |  Getters & Setters
41
     | ------------------------------------------------------------------------------------------------
42
     */
43
    /**
44
     * Get config.
45
     *
46
     * @param  string  $key
47
     * @param  mixed   $default
48
     *
49
     * @return mixed
50
     */
51 57
    private function get($key, $default = null)
52
    {
53 57
        return $this->config->get("log-viewer.$key", $default);
54
    }
55
56
    /* ------------------------------------------------------------------------------------------------
57
     |  Main Functions
58
     | ------------------------------------------------------------------------------------------------
59
     */
60
    /**
61
     * Make level icon.
62
     *
63
     * @param  string       $level
64
     * @param  string|null  $default
65
     *
66
     * @return string
67
     */
68 39
    public function icon($level, $default = null)
69
    {
70 39
        return '<i class="'.$this->get("icons.$level", $default).'"></i>';
71
    }
72
73
    /**
74
     * Get level color.
75
     *
76
     * @param  string       $level
77
     * @param  string|null  $default
78
     *
79
     * @return string
80
     */
81 27
    public function color($level, $default = null)
82
    {
83 27
        return $this->get("colors.levels.$level", $default);
84
    }
85
86
    /**
87
     * Get strings to highlight.
88
     *
89
     * @param  array  $default
90
     *
91
     * @return string
92
     */
93 9
    public function toHighlight(array $default = [])
94
    {
95 9
        return $this->get("highlight", $default);
96
    }
97
}
98