Passed
Push — main ( 545ade...3cfdef )
by Andrey
79:39 queued 77:29
created

Config   A

Complexity

Total Complexity 14

Size/Duplication

Total Lines 153
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 4
Bugs 0 Features 0
Metric Value
eloc 30
c 4
b 0
f 0
dl 0
loc 153
ccs 38
cts 38
cp 1
rs 10
wmc 14

12 Methods

Rating   Name   Duplication   Size   Complexity  
A basePath() 0 5 1
A defaultLocale() 0 5 2
A resourcesPath() 0 5 1
A sourcePath() 0 5 1
A getCase() 0 5 1
A localesPath() 0 5 1
A ignores() 0 5 1
A packages() 0 8 1
A excludes() 0 5 1
A fallbackLocale() 0 5 2
A hasInline() 0 5 1
A hasAlignment() 0 5 1
1
<?php
2
3
namespace Helldar\LaravelLangPublisher\Support;
4
5
use Helldar\LaravelLangPublisher\Concerns\Logger;
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
    use Logger;
0 ignored issues
show
Bug introduced by
The trait Helldar\LaravelLangPublisher\Concerns\Logger requires the property $output which is not provided by Helldar\LaravelLangPublisher\Support\Config.
Loading history...
13
14
    public const KEY_PRIVATE = 'lang-publisher-private';
15
16
    public const KEY_PUBLIC = 'lang-publisher';
17
18
    /**
19
     * Getting a list of packages from which to synchronize localization files.
20
     *
21
     * @return array
22
     */
23 18
    public function packages(): array
24
    {
25 18
        $this->log('Getting a list of supported packages...');
26
27 18
        $private = Illuminate::get(self::KEY_PRIVATE . '.packages', []);
28 18
        $public  = Illuminate::get(self::KEY_PUBLIC . '.packages', []);
29
30 18
        return array_values(array_merge($public, $private));
31
    }
32
33
    /**
34
     * Getting the path to the sources of the English localization.
35
     *
36
     * @return string
37
     */
38 20
    public function basePath(): string
39
    {
40 20
        $this->log('Getting the path to the sources of the English localization...');
41
42 20
        return Illuminate::get(self::KEY_PRIVATE . '.path.base');
43
    }
44
45
    /**
46
     * Getting the path to source locale.
47
     *
48
     * @return string
49
     */
50 20
    public function sourcePath(): string
51
    {
52 20
        $this->log('Getting the path to source locale...');
53
54 20
        return Illuminate::get(self::KEY_PRIVATE . '.path.source');
55
    }
56
57
    /**
58
     * Getting the path to localizations.
59
     *
60
     * @return string
61
     */
62 16
    public function localesPath(): string
63
    {
64 16
        $this->log('Getting the path to localizations...');
65
66 16
        return Illuminate::get(self::KEY_PRIVATE . '.path.locales');
67
    }
68
69
    /**
70
     * Getting the path to resources of the application.
71
     *
72
     * @return string
73
     */
74 20
    public function resourcesPath(): string
75
    {
76 20
        $this->log('Getting the path to resources of the application...');
77
78 20
        return Illuminate::get(self::KEY_PRIVATE . '.path.target');
79
    }
80
81
    /**
82
     * Determines what type of files to use when updating language files.
83
     *
84
     * @return bool
85
     */
86 11
    public function hasInline(): bool
87
    {
88 11
        $this->log('Determines what type of files to use when updating language files...');
89
90 11
        return Illuminate::get(self::KEY_PUBLIC . '.inline');
91
    }
92
93
    /**
94
     * Determines whether values should be aligned when saving.
95
     *
96
     * @return bool
97
     */
98 11
    public function hasAlignment(): bool
99
    {
100 11
        $this->log('Determines whether values should be aligned when saving...');
101
102 11
        return Illuminate::get(self::KEY_PUBLIC . '.alignment');
103
    }
104
105
    /**
106
     * Key exclusion when combining.
107
     *
108
     * @return array
109
     */
110 10
    public function excludes(): array
111
    {
112 10
        $this->log('Key exclusion when combining...');
113
114 10
        return Illuminate::get(self::KEY_PUBLIC . '.exclude', []);
115
    }
116
117
    /**
118
     * List of ignored localizations.
119
     *
120
     * @return array
121
     */
122 10
    public function ignores(): array
123
    {
124 10
        $this->log('List of ignored localizations...');
125
126 10
        return Illuminate::get(self::KEY_PUBLIC . '.ignore', []);
127
    }
128
129
    /**
130
     * Getting the value of the option to change the case of keys.
131
     *
132
     * @return int
133
     */
134 11
    public function getCase(): int
135
    {
136 11
        $this->log('Getting the value of the option to change the case of keys...');
137
138 11
        return Illuminate::get(self::KEY_PUBLIC . '.case', Caseable::NO_CASE);
139
    }
140
141
    /**
142
     * Getting the default localization name.
143
     *
144
     * @return string
145
     */
146 4
    public function defaultLocale(): string
147
    {
148 4
        $this->log('Getting the default localization name...');
149
150 4
        return Illuminate::get('app.locale') ?: $this->fallbackLocale();
151
    }
152
153
    /**
154
     * Getting the fallback localization name.
155
     *
156
     * @return string
157
     */
158 3
    public function fallbackLocale(): string
159
    {
160 3
        $this->log('Getting the fallback localization name...');
161
162 3
        return Illuminate::get('app.fallback_locale') ?: LocalesList::ENGLISH;
163
    }
164
}
165