1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Finder\Pipelines\Finder; |
4
|
|
|
|
5
|
|
|
use League\Pipeline\Pipeline; |
6
|
|
|
use Operador\Contracts\StageInterface; |
7
|
|
|
|
8
|
|
|
use Symfony\Component\Finder\Finder; |
9
|
|
|
use Support\Helps\DebugHelper; |
10
|
|
|
use Operador\Contracts\Stage as StageBase; |
11
|
|
|
use Finder\Pipelines\Builders\FileBuilder; |
12
|
|
|
use Finder\Pipelines\Builders\DirectoryBuilder; |
13
|
|
|
use Finder\Pipelines\Builders\ProjectBuilder; |
14
|
|
|
|
15
|
|
|
class Directory extends StageBase |
16
|
|
|
{ |
17
|
|
|
protected $finder = false; |
18
|
|
|
|
19
|
|
|
// Have |
20
|
|
|
protected $files = []; |
21
|
|
|
protected $directorys = []; |
22
|
|
|
|
23
|
|
|
|
24
|
|
|
public function __invoke($payload) |
25
|
|
|
{ |
26
|
|
|
// find all files in the current directory |
27
|
|
|
$targetPath = $payload->getTargetPath(); |
28
|
|
|
$this->info('Analisando Pasta: '.$targetPath); |
29
|
|
|
|
30
|
|
|
$finder = $this->getFinder($targetPath); |
31
|
|
|
// check if there are any search results |
32
|
|
|
if (!$finder->hasResults()) { |
33
|
|
|
$this->info('No Results: '.$targetPath); |
34
|
|
|
return $payload; |
35
|
|
|
} |
36
|
|
|
|
37
|
|
|
/** |
38
|
|
|
* Mappers |
39
|
|
|
*/ |
40
|
|
|
foreach ($finder as $file) { |
41
|
|
|
if ($file->getType() == 'file') { |
42
|
|
|
$payload->files[$file->getBasename()] = $file; |
43
|
|
|
} else { |
44
|
|
|
$payload->directorys[$file->getBasename()] = $file; |
45
|
|
|
} |
46
|
|
|
} |
47
|
|
|
|
48
|
|
|
/** |
49
|
|
|
* Sub Pipelines |
50
|
|
|
*/ |
51
|
|
|
$pipeline = DirectoryBuilder::getPipelineWithOutput($this->getOutput()); |
52
|
|
|
foreach ($payload->directorys as $directory) { |
53
|
|
|
$this->info('Process Sub Pasta: '.$directory->getRealPath()); |
54
|
|
|
$pipeline->process( |
55
|
|
|
\Fabrica\Entities\DirectoryEntity::make($directory) |
56
|
|
|
); |
57
|
|
|
} |
58
|
|
|
$pipeline = FileBuilder::getPipelineWithOutput($this->getOutput()); |
59
|
|
|
foreach ($payload->files as $file) { |
60
|
|
|
$this->info('Process Sub File: '.$file->getRealPath()); |
61
|
|
|
$pipeline->process( |
62
|
|
|
\Fabrica\Entities\FileEntity::make($file) |
63
|
|
|
); |
64
|
|
|
} |
65
|
|
|
|
66
|
|
|
|
67
|
|
|
/** |
68
|
|
|
* Caso seja Projeto |
69
|
|
|
*/ |
70
|
|
|
if($payload->isProject()) { |
71
|
|
|
$pipeline = ProjectBuilder::getPipelineWithOutput($this->getOutput()); |
72
|
|
|
// Process Pipeline |
73
|
|
|
return $pipeline( |
74
|
|
|
\Fabrica\Entities\ProjectEntity::make($payload) |
75
|
|
|
); |
76
|
|
|
} |
77
|
|
|
|
78
|
|
|
return $payload; |
79
|
|
|
|
80
|
|
|
} |
81
|
|
|
|
82
|
|
|
|
83
|
|
|
|
84
|
|
|
public function getTargetPath() |
85
|
|
|
{ |
86
|
|
|
} |
87
|
|
|
|
88
|
|
|
|
89
|
|
|
|
90
|
|
|
public function getFinder($targetPath, $fast = true) |
91
|
|
|
{ |
92
|
|
|
$finder = false; |
93
|
|
|
try { |
94
|
|
|
if (!$finder) { |
95
|
|
|
$finder = new Finder(); |
96
|
|
|
$finder->ignoreUnreadableDirs(); |
97
|
|
|
if ($fast) { |
98
|
|
|
if (file_exists($targetPath.'gitignore')) { |
99
|
|
|
// excludes files/directories matching the .gitignore patterns |
100
|
|
|
$finder->ignoreVCSIgnored(true); |
101
|
|
|
} |
102
|
|
|
} |
103
|
|
|
// Ignorar Recursividade |
104
|
|
|
$finder->depth('== 0'); |
105
|
|
|
// Buscar Pastas e Arquivos |
106
|
|
|
$finder->in($targetPath); |
107
|
|
|
} |
108
|
|
|
} catch (\Symfony\Component\Finder\Exception\DirectoryNotFoundException $e) { |
109
|
|
|
DebugHelper::warning('Diretório não existe: '. $e->getMessage()); |
110
|
|
|
} catch (Exception $e) { |
|
|
|
|
111
|
|
|
DebugHelper::warning('Exceção capturada: '. $e->getMessage()); |
112
|
|
|
} |
113
|
|
|
|
114
|
|
|
return $finder; |
115
|
|
|
} |
116
|
|
|
} |
Scrutinizer analyzes your
composer.json
/composer.lock
file if available to determine the classes, and functions that are defined by your dependencies.It seems like the listed class was neither found in your dependencies, nor was it found in the analyzed files in your repository. If you are using some other form of dependency management, you might want to disable this analysis.