Passed
Push — main ( 8320d0...c2748c )
by Andrey
45:28 queued 42:35
created

Config::plugins()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 8
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 5
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 4
c 1
b 0
f 0
nc 1
nop 0
dl 0
loc 8
ccs 5
cts 5
cp 1
crap 1
rs 10
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 22
    public function packages(): array
24
    {
25 22
        $this->log('Getting a list of supported packages...');
26
27 22
        $private = Illuminate::get(self::KEY_PRIVATE . '.packages', []);
28 22
        $public  = Illuminate::get(self::KEY_PUBLIC . '.packages', []);
29
30 22
        return array_values(array_merge($public, $private));
31
    }
32
33 14
    public function plugins(): array
34
    {
35 14
        $this->log('Getting a list of supported plugins...');
36
37 14
        $private = Illuminate::get(self::KEY_PRIVATE . '.plugins', []);
38 14
        $public  = Illuminate::get(self::KEY_PUBLIC . '.plugins', []);
39
40 14
        return array_values(array_merge($public, $private));
41
    }
42
43
    /**
44
     * Retrieving a link to the "vendor" directory.
45
     *
46
     * @return string
47
     */
48 24
    public function basePath(): string
49
    {
50 24
        $this->log('Retrieving a link to the "vendor" directory...');
51
52 24
        return Illuminate::get(self::KEY_PRIVATE . '.path.base');
53
    }
54
55
    /**
56
     * Getting the name of the directory with the source files of the English localization.
57
     *
58
     * @return string
59
     */
60 24
    public function sourcePath(): string
61
    {
62 24
        $this->log('Getting the name of the directory with the source files of the English localization...');
63
64 24
        return Illuminate::get(self::KEY_PRIVATE . '.path.source');
65
    }
66
67
    /**
68
     * Getting the path to localizations.
69
     *
70
     * @return string
71
     */
72 19
    public function localesPath(): string
73
    {
74 19
        $this->log('Getting the path to localizations...');
75
76 19
        return Illuminate::get(self::KEY_PRIVATE . '.path.locales');
77
    }
78
79
    /**
80
     * Getting the path to resources of the application.
81
     *
82
     * @return string
83
     */
84 24
    public function resourcesPath(): string
85
    {
86 24
        $this->log('Getting the path to resources of the application...');
87
88 24
        return Illuminate::get(self::KEY_PRIVATE . '.path.target');
89
    }
90
91
    /**
92
     * Determines what type of files to use when updating language files.
93
     *
94
     * @return bool
95
     */
96 15
    public function hasInline(): bool
97
    {
98 15
        $this->log('Determines what type of files to use when updating language files...');
99
100 15
        return Illuminate::get(self::KEY_PUBLIC . '.inline');
101
    }
102
103
    /**
104
     * Determines whether values should be aligned when saving.
105
     *
106
     * @return bool
107
     */
108 14
    public function hasAlignment(): bool
109
    {
110 14
        $this->log('Determines whether values should be aligned when saving...');
111
112 14
        return Illuminate::get(self::KEY_PUBLIC . '.alignment');
113
    }
114
115
    /**
116
     * Key exclusion when combining.
117
     *
118
     * @return array
119
     */
120 14
    public function excludes(): array
121
    {
122 14
        $this->log('Key exclusion when combining...');
123
124 14
        return Illuminate::get(self::KEY_PUBLIC . '.exclude', []);
125
    }
126
127
    /**
128
     * List of ignored localizations.
129
     *
130
     * @return array
131
     */
132 13
    public function ignores(): array
133
    {
134 13
        $this->log('List of ignored localizations...');
135
136 13
        return Illuminate::get(self::KEY_PUBLIC . '.ignore', []);
137
    }
138
139
    /**
140
     * Getting the value of the option to change the case of keys.
141
     *
142
     * @return int
143
     */
144 14
    public function getCase(): int
145
    {
146 14
        $this->log('Getting the value of the option to change the case of keys...');
147
148 14
        return Illuminate::get(self::KEY_PUBLIC . '.case', Caseable::NO_CASE);
149
    }
150
151
    /**
152
     * Getting the default localization name.
153
     *
154
     * @return string
155
     */
156 5
    public function defaultLocale(): string
157
    {
158 5
        $this->log('Getting the default localization name...');
159
160 5
        return Illuminate::get('app.locale') ?: $this->fallbackLocale();
161
    }
162
163
    /**
164
     * Getting the fallback localization name.
165
     *
166
     * @return string
167
     */
168 4
    public function fallbackLocale(): string
169
    {
170 4
        $this->log('Getting the fallback localization name...');
171
172 4
        return Illuminate::get('app.fallback_locale') ?: LocalesList::ENGLISH;
173
    }
174
}
175