/
Contains.php
43 lines (33 loc) · 1.03 KB
/
Contains.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
<?php
namespace LaravelLang\Lang\Concerns;
use Helldar\Support\Facades\Helpers\Filesystem\Directory;
use Helldar\Support\Facades\Helpers\Str;
use LaravelLang\Lang\Constants\Locales;
trait Contains
{
protected function isMainJson(string $filename): bool
{
if ($this->isEnglishJson($filename)) {
return true;
}
$locale = Str::before($filename, '.');
$path = $this->app->localePath($locale);
return $this->isJson($filename) && Directory::exists($path);
}
protected function isEnglishJson(string $filename): bool
{
return $this->isJson($filename) && str_starts_with($filename, Locales::ENGLISH);
}
protected function isJson(string $filename): bool
{
return str_ends_with($filename, 'json');
}
protected function isMarkdown(string $filename): bool
{
return str_ends_with($filename, 'md');
}
protected function isValidation(string $filename): bool
{
return str_starts_with($filename, 'validation');
}
}