|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
/* |
|
4
|
|
|
* This file is part of the "andrey-helldar/laravel-lang-publisher" project. |
|
5
|
|
|
* |
|
6
|
|
|
* For the full copyright and license information, please view the LICENSE |
|
7
|
|
|
* file that was distributed with this source code. |
|
8
|
|
|
* |
|
9
|
|
|
* @author Andrey Helldar <[email protected]> |
|
10
|
|
|
* |
|
11
|
|
|
* @copyright 2021 Andrey Helldar |
|
12
|
|
|
* |
|
13
|
|
|
* @license MIT |
|
14
|
|
|
* |
|
15
|
|
|
* @see https://github.com/andrey-helldar/laravel-lang-publisher |
|
16
|
|
|
*/ |
|
17
|
|
|
|
|
18
|
|
|
declare(strict_types=1); |
|
19
|
|
|
|
|
20
|
|
|
namespace Helldar\LaravelLangPublisher\Helpers; |
|
21
|
|
|
|
|
22
|
|
|
use Helldar\Contracts\LangPublisher\Provider; |
|
23
|
|
|
use Helldar\LaravelLangPublisher\Constants\Config as ConfigConst; |
|
24
|
|
|
use Helldar\LaravelLangPublisher\Exceptions\UnknownPluginInstanceException; |
|
25
|
|
|
use Helldar\Support\Facades\Helpers\Ables\Arrayable; |
|
26
|
|
|
use Helldar\Support\Facades\Helpers\Instance; |
|
27
|
|
|
use Illuminate\Support\Facades\Config as Illuminate; |
|
28
|
|
|
|
|
29
|
|
|
class Config |
|
30
|
|
|
{ |
|
31
|
|
|
public function vendor(): string |
|
32
|
|
|
{ |
|
33
|
|
|
return $this->getPrivate('path.base'); |
|
34
|
|
|
} |
|
35
|
|
|
|
|
36
|
|
|
public function resources(): string |
|
37
|
|
|
{ |
|
38
|
|
|
return $this->getPrivate('path.resources'); |
|
39
|
|
|
} |
|
40
|
|
|
|
|
41
|
|
|
public function plugins(): array |
|
42
|
|
|
{ |
|
43
|
|
|
$private = $this->getPrivate('plugins'); |
|
44
|
|
|
$public = $this->getPublic('plugins'); |
|
45
|
|
|
|
|
46
|
|
|
return Arrayable::of($public) |
|
47
|
|
|
->addUnique($private) |
|
48
|
|
|
->unique() |
|
49
|
|
|
->values() |
|
50
|
|
|
->map(static function (string $plugin) { |
|
51
|
|
|
if (Instance::of($plugin, Provider::class)) { |
|
52
|
|
|
return new $plugin(); |
|
53
|
|
|
} |
|
54
|
|
|
|
|
55
|
|
|
throw new UnknownPluginInstanceException($plugin); |
|
56
|
|
|
})->get(); |
|
57
|
|
|
} |
|
58
|
|
|
|
|
59
|
|
|
public function hasInline(): bool |
|
60
|
|
|
{ |
|
61
|
|
|
return $this->getPublic('inline'); |
|
62
|
|
|
} |
|
63
|
|
|
|
|
64
|
|
|
public function hasAlignment(): bool |
|
65
|
|
|
{ |
|
66
|
|
|
return $this->getPublic('alignment'); |
|
67
|
|
|
} |
|
68
|
|
|
|
|
69
|
|
|
public function excludes(): array |
|
70
|
|
|
{ |
|
71
|
|
|
return $this->getPublic('excludes'); |
|
72
|
|
|
} |
|
73
|
|
|
|
|
74
|
|
|
public function case(): int |
|
75
|
|
|
{ |
|
76
|
|
|
return $this->getPublic('case'); |
|
77
|
|
|
} |
|
78
|
|
|
|
|
79
|
|
|
protected function getPrivate(string $key) |
|
80
|
|
|
{ |
|
81
|
|
|
$key = $this->privateKey($key); |
|
82
|
|
|
|
|
83
|
|
|
return Illuminate::get($key); |
|
84
|
|
|
} |
|
85
|
|
|
|
|
86
|
|
|
protected function getPublic(string $key) |
|
87
|
|
|
{ |
|
88
|
|
|
$key = $this->publicKey($key); |
|
89
|
|
|
|
|
90
|
|
|
return Illuminate::get($key); |
|
91
|
|
|
} |
|
92
|
|
|
|
|
93
|
|
|
protected function privateKey(string $suffix): string |
|
94
|
|
|
{ |
|
95
|
|
|
return ConfigConst::PRIVATE_KEY . '.' . $suffix; |
|
96
|
|
|
} |
|
97
|
|
|
|
|
98
|
|
|
protected function publicKey(string $suffix): string |
|
99
|
|
|
{ |
|
100
|
|
|
return ConfigConst::PUBLIC_KEY . '.' . $suffix; |
|
101
|
|
|
} |
|
102
|
|
|
} |
|
103
|
|
|
|