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\Concerns; |
21
|
|
|
|
22
|
|
|
use Helldar\LaravelLangPublisher\Facades\Helpers\Config; |
23
|
|
|
use Illuminate\Support\Collection; |
24
|
|
|
|
25
|
|
|
trait Paths |
26
|
|
|
{ |
27
|
|
|
protected $trim_chars = '/\\'; |
28
|
|
|
|
29
|
|
|
protected $directory_separator = DIRECTORY_SEPARATOR; |
30
|
|
|
|
31
|
|
|
protected function extension(string $filename): string |
32
|
|
|
{ |
33
|
|
|
return pathinfo($filename, PATHINFO_EXTENSION); |
|
|
|
|
34
|
|
|
} |
35
|
|
|
|
36
|
|
|
protected function filename(string $filename): string |
37
|
|
|
{ |
38
|
|
|
return pathinfo($filename, PATHINFO_FILENAME); |
|
|
|
|
39
|
|
|
} |
40
|
|
|
|
41
|
|
|
protected function path(string $base_path, ...$parameters): string |
42
|
|
|
{ |
43
|
|
|
$base_path = rtrim($base_path, $this->trim_chars); |
44
|
|
|
|
45
|
|
|
$parameters = Collection::make($parameters) |
46
|
|
|
->map(function (string $parameter) { |
47
|
|
|
return trim($parameter, $this->trim_chars); |
48
|
|
|
})->implode($this->directory_separator); |
49
|
|
|
|
50
|
|
|
return $base_path . $this->directory_separator . $parameters; |
51
|
|
|
} |
52
|
|
|
|
53
|
|
|
protected function vendorPath(string ...$parameters): string |
54
|
|
|
{ |
55
|
|
|
return $this->path(Config::vendor(), ...$parameters); |
56
|
|
|
} |
57
|
|
|
|
58
|
|
|
protected function resourcesPath(string ...$parameters): string |
59
|
|
|
{ |
60
|
|
|
return $this->path(Config::resources(), ...$parameters); |
61
|
|
|
} |
62
|
|
|
} |
63
|
|
|
|