Passed
Push — 10.x ( e0b1ce...c0ee15 )
by Andrey
14:47
created

Config::publicKey()   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 1
Bugs 0 Features 0
Metric Value
eloc 1
c 1
b 0
f 0
dl 0
loc 3
ccs 2
cts 2
cp 1
rs 10
cc 1
nc 1
nop 0
crap 1
1
<?php
2
3
namespace Helldar\LaravelLangPublisher\Support;
4
5
use Helldar\LaravelLangPublisher\Constants\Config as ConfigNames;
6
use Helldar\LaravelLangPublisher\Constants\Locales as LocalesList;
7
use Helldar\PrettyArray\Contracts\Caseable;
8
use Illuminate\Support\Facades\Config as Illuminate;
9
10
final class Config
11
{
12
    /**
13
     * Getting a list of packages from which to synchronize localization files.
14
     *
15
     * @return array
16
     */
17
    public function packages(): array
18
    {
19
        return $this->getList('packages');
20
    }
21
22
    /**
23 22
     * Getting a list of plugins from which to synchronize localization files.
24
     *
25 22
     * @return array
26
     */
27 22
    public function plugins(): array
28 22
    {
29
        return $this->getList('plugins');
30 22
    }
31
32
    public function vendor(): string
33
    {
34
        return Illuminate::get($this->privateKey() . '.path.base');
35
    }
36
37
    public function resources(): string
38 24
    {
39
        return Illuminate::get($this->privateKey() . '.path.target');
40 24
    }
41
42 24
    public function source(): string
43
    {
44
        return Illuminate::get($this->privateKey() . '.path.source');
45
    }
46
47
    public function locales(): string
48
    {
49
        return Illuminate::get($this->privateKey() . '.path.locales');
50 24
    }
51
52 24
    public function excludes(): array
53
    {
54 24
        return Illuminate::get($this->publicKey() . '.exclude', []);
55
    }
56
57
    public function ignores(): array
58
    {
59
        return Illuminate::get($this->publicKey() . '.ignore', []);
60
    }
61
62 19
    public function getCase(): int
63
    {
64 19
        return Illuminate::get($this->publicKey() . '.case', Caseable::NO_CASE);
65
    }
66 19
67
    public function defaultLocale(): string
68
    {
69
        return Illuminate::get('app.locale') ?: $this->fallbackLocale();
70
    }
71
72
    public function fallbackLocale(): string
73
    {
74 24
        return Illuminate::get('app.fallback_locale') ?: LocalesList::ENGLISH;
75
    }
76 24
77
    public function hasInline(): bool
78 24
    {
79
        return Illuminate::get($this->publicKey() . '.inline');
80
    }
81
82
    public function hasAlignment(): bool
83
    {
84
        return Illuminate::get($this->publicKey() . '.alignment');
85
    }
86 15
87
    protected function getList(string $key): array
88 15
    {
89
        $private = Illuminate::get($this->privateKey() . '.' . $key, []);
90 15
        $public  = Illuminate::get($this->publicKey() . '.' . $key, []);
91
92
        return array_values(array_merge($private, $public));
93
    }
94
95
    protected function privateKey(): string
96
    {
97
        return ConfigNames::KEY_PRIVATE;
98 14
    }
99
100 14
    protected function publicKey(): string
101
    {
102 14
        return ConfigNames::KEY_PUBLIC;
103
    }
104
}
105