Config   A
last analyzed

Complexity

Total Complexity 11

Size/Duplication

Total Lines 57
Duplicated Lines 0 %

Test Coverage

Coverage 82.61%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 13
c 1
b 0
f 0
dl 0
loc 57
ccs 19
cts 23
cp 0.8261
rs 10
wmc 11

11 Methods

Rating   Name   Duplication   Size   Complexity  
A filename() 0 3 1
A connection() 0 3 1
A cacheTtl() 0 3 1
A useCache() 0 3 1
A set() 0 3 1
A name() 0 3 1
A get() 0 3 1
A defaultRole() 0 3 1
A compileKey() 0 3 1
A useCanDirective() 0 3 1
A useBlade() 0 3 1
1
<?php
2
3
namespace Helldar\Roles\Support;
4
5
use Illuminate\Support\Facades\Config as IlluminateConfig;
6
7
class Config
8
{
9
    public const NAME = 'roles';
10
11 138
    public function get($key, $default = null)
12
    {
13 138
        return IlluminateConfig::get($this->compileKey($key), $default);
14
    }
15
16 54
    public function set($key, $value): void
17
    {
18 54
        IlluminateConfig::set($this->compileKey($key), $value);
19 54
    }
20
21 138
    public function name(): string
22
    {
23 138
        return static::NAME;
24
    }
25
26 138
    public function connection(): string
27
    {
28 138
        return $this->get('connection', 'mysql');
29
    }
30
31
    public function useBlade(): bool
32
    {
33
        return (bool) $this->get('use_blade', false);
34
    }
35
36
    public function useCanDirective(): bool
37
    {
38
        return (bool) $this->get('use_can_directive', false);
39
    }
40
41 138
    public function useCache(): bool
42
    {
43 138
        return (bool) $this->get('use_cache', false);
44
    }
45
46 6
    public function cacheTtl(): int
47
    {
48 6
        return (int) $this->get('cache_ttl', 3600);
49
    }
50
51 138
    public function filename()
52
    {
53 138
        return $this->name() . '.php';
54
    }
55
56 6
    public function defaultRole(): ?string
57
    {
58 6
        return $this->get('default_role');
59
    }
60
61 138
    protected function compileKey($key): string
62
    {
63 138
        return $this->name() . '.' . $key;
64
    }
65
}
66