Passed
Push — features/split-packages ( 745907...9ff8f9 )
by Andrey
14:17
created

Config::plugins()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 8
Code Lines 4

Duplication

Lines 0
Ratio 0 %

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
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
    public function packages(): array
24
    {
25
        $this->log('Getting a list of supported packages...');
26
27
        $private = Illuminate::get(self::KEY_PRIVATE . '.packages', []);
28
        $public  = Illuminate::get(self::KEY_PUBLIC . '.packages', []);
29
30
        return array_values(array_merge($public, $private));
31
    }
32
33
    public function plugins(): array
34
    {
35
        $this->log('Getting a list of supported plugins...');
36
37
        $private = Illuminate::get(self::KEY_PRIVATE . '.plugins', []);
38
        $public  = Illuminate::get(self::KEY_PUBLIC . '.plugins', []);
39
40
        return array_values(array_merge($public, $private));
41
    }
42
43
    /**
44
     * Retrieving a link to the "vendor" directory.
45
     *
46
     * @return string
47
     */
48
    public function basePath(): string
49
    {
50
        $this->log('Retrieving a link to the "vendor" directory...');
51
52
        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
    public function sourcePath(): string
61
    {
62
        $this->log('Getting the name of the directory with the source files of the English localization...');
63
64
        return Illuminate::get(self::KEY_PRIVATE . '.path.source');
65
    }
66
67
    /**
68
     * Getting the path to localizations.
69
     *
70
     * @return string
71
     */
72
    public function localesPath(): string
73
    {
74
        $this->log('Getting the path to localizations...');
75
76
        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
    public function resourcesPath(): string
85
    {
86
        $this->log('Getting the path to resources of the application...');
87
88
        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
    public function hasInline(): bool
97
    {
98
        $this->log('Determines what type of files to use when updating language files...');
99
100
        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
    public function hasAlignment(): bool
109
    {
110
        $this->log('Determines whether values should be aligned when saving...');
111
112
        return Illuminate::get(self::KEY_PUBLIC . '.alignment');
113
    }
114
115
    /**
116
     * Key exclusion when combining.
117
     *
118
     * @return array
119
     */
120
    public function excludes(): array
121
    {
122
        $this->log('Key exclusion when combining...');
123
124
        return Illuminate::get(self::KEY_PUBLIC . '.exclude', []);
125
    }
126
127
    /**
128
     * List of ignored localizations.
129
     *
130
     * @return array
131
     */
132
    public function ignores(): array
133
    {
134
        $this->log('List of ignored localizations...');
135
136
        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
    public function getCase(): int
145
    {
146
        $this->log('Getting the value of the option to change the case of keys...');
147
148
        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
    public function defaultLocale(): string
157
    {
158
        $this->log('Getting the default localization name...');
159
160
        return Illuminate::get('app.locale') ?: $this->fallbackLocale();
161
    }
162
163
    /**
164
     * Getting the fallback localization name.
165
     *
166
     * @return string
167
     */
168
    public function fallbackLocale(): string
169
    {
170
        $this->log('Getting the fallback localization name...');
171
172
        return Illuminate::get('app.fallback_locale') ?: LocalesList::ENGLISH;
173
    }
174
}
175