Passed
Pull Request — main (#123)
by Andrey
29:36 queued 14:38
created

Config   A

Complexity

Total Complexity 11

Size/Duplication

Total Lines 68
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 11
eloc 22
c 1
b 0
f 0
dl 0
loc 68
rs 10

11 Methods

Rating   Name   Duplication   Size   Complexity  
A publicKey() 0 3 1
A privateKey() 0 3 1
A case() 0 3 1
A resources() 0 3 1
A getPublic() 0 5 1
A hasAlignment() 0 3 1
A vendor() 0 3 1
A plugins() 0 12 1
A excludes() 0 3 1
A getPrivate() 0 5 1
A hasInline() 0 3 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Helldar\LaravelLangPublisher\Config;
6
7
use Helldar\LaravelLangPublisher\Constants\Config as ConfigConst;
8
use Helldar\Support\Facades\Helpers\Ables\Arrayable;
9
use Helldar\Support\Facades\Helpers\Instance;
10
11
class Config
12
{
13
    public function vendor(): string
14
    {
15
        return $this->getPrivate('path.base');
16
    }
17
18
    public function resources(): string
19
    {
20
        return $this->getPrivate('path.resources');
21
    }
22
23
    public function plugins(): array
24
    {
25
        $private = $this->getPrivate('plugins');
26
        $public  = $this->getPublic('plugins');
27
28
        return Arrayable::of($public)
29
            ->merge($private)
30
            ->unique()
31
            ->filter(static function (string $plugin) {
32
                return Instance::exists($plugin);
33
            })
34
            ->get();
35
    }
36
37
    public function hasInline(): bool
38
    {
39
        return $this->getPublic('inline');
40
    }
41
42
    public function hasAlignment(): bool
43
    {
44
        return $this->getPublic('alignment');
45
    }
46
47
    public function excludes(): array
48
    {
49
        return $this->getPublic('excludes');
50
    }
51
52
    public function case(): int
53
    {
54
        return $this->getPublic('case');
55
    }
56
57
    protected function getPrivate(string $key)
58
    {
59
        $key = $this->privateKey($key);
60
61
        return config($key);
62
    }
63
64
    protected function getPublic(string $key)
65
    {
66
        $key = $this->publicKey($key);
67
68
        return config($key);
69
    }
70
71
    protected function privateKey(string $suffix): string
72
    {
73
        return ConfigConst::PRIVATE_KEY . '.' . $suffix;
74
    }
75
76
    protected function publicKey(string $suffix): string
77
    {
78
        return ConfigConst::PUBLIC_KEY . '.' . $suffix;
79
    }
80
}
81