Passed
Push — master ( c89bf9...5eeb6f )
by Andrey
03:48
created

Config::defaultRole()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
cc 1
eloc 1
c 0
b 0
f 0
nc 1
nop 0
dl 0
loc 3
ccs 2
cts 2
cp 1
crap 1
rs 10
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 114
    public function get($key, $default = null)
12
    {
13 114
        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 114
    public function name(): string
22
    {
23 114
        return static::NAME;
24
    }
25
26 114
    public function connection(): string
27
    {
28 114
        return $this->get('connection', 'mysql');
29
    }
30
31 114
    public function useBlade(): bool
32
    {
33 114
        return (bool) $this->get('use_blade', false);
34
    }
35
36 114
    public function useCanDirective(): bool
37
    {
38 114
        return (bool) $this->get('use_can_directive', false);
39
    }
40
41 72
    public function useCache(): bool
42
    {
43 72
        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 114
    public function filename()
52
    {
53 114
        return $this->name() . '.php';
54
    }
55
56 6
    public function defaultRole(): ?string
57
    {
58 6
        return $this->get('default_role');
59
    }
60
61 114
    protected function compileKey($key): string
62
    {
63 114
        return $this->name() . '.' . $key;
64
    }
65
}
66