-
-
Notifications
You must be signed in to change notification settings - Fork 3.1k
/
Package.php
57 lines (42 loc) · 1.16 KB
/
Package.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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
<?php
namespace LaravelLang\Lang\Support;
use Helldar\Support\Facades\Helpers\Filesystem\Directory;
use Helldar\Support\Facades\Helpers\Str;
class Package
{
protected ?string $path;
protected array $filter = ['$', 'self::', 'static::', 'auth.', 'pagination.', 'passwords.', 'validation.'];
public function __construct(
protected Finder $finder,
protected Parser $parser
) {
}
public function some(): self
{
return $this;
}
public function path(string $path): self
{
Directory::validate($path);
$this->path = realpath($path);
return $this;
}
public function content(): array
{
$files = $this->files();
$items = $this->parsed($files);
return $this->filter($items);
}
protected function files(): array
{
return $this->finder->get($this->path);
}
protected function parsed(array $files): array
{
return $this->parser->files($files)->get();
}
protected function filter(array $items): array
{
return array_filter(array_keys($items), fn ($value) => ! Str::contains($value, $this->filter));
}
}