|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace Jobtech\LaravelChunky; |
|
4
|
|
|
|
|
5
|
|
|
use Illuminate\Container\Container; |
|
6
|
|
|
use Jobtech\LaravelChunky\Contracts\MergeManager as MergeManagerContract; |
|
7
|
|
|
use Jobtech\LaravelChunky\Handlers\MergeHandler; |
|
|
|
|
|
|
8
|
|
|
use Jobtech\LaravelChunky\Strategies\Contracts\MergeStrategy; |
|
9
|
|
|
use Jobtech\LaravelChunky\Support\MergeFilesystem; |
|
10
|
|
|
|
|
11
|
|
|
class MergeManager implements MergeManagerContract |
|
12
|
|
|
{ |
|
13
|
|
|
/** @var ?MergeManager */ |
|
14
|
|
|
private static $instance; |
|
15
|
|
|
|
|
16
|
|
|
/** @var \Jobtech\LaravelChunky\ChunkySettings */ |
|
17
|
|
|
private ChunkySettings $settings; |
|
18
|
|
|
|
|
19
|
|
|
/** @var \Jobtech\LaravelChunky\Support\MergeFilesystem */ |
|
20
|
|
|
private $mergeFilesystem; |
|
21
|
|
|
|
|
22
|
|
|
/** |
|
23
|
|
|
* @var \Jobtech\LaravelChunky\Handlers\MergeHandler|null |
|
24
|
|
|
*/ |
|
25
|
|
|
private ?MergeHandler $handler; |
|
|
|
|
|
|
26
|
|
|
|
|
27
|
|
|
public function __construct(ChunkySettings $settings) |
|
28
|
|
|
{ |
|
29
|
|
|
$this->settings = $settings; |
|
30
|
|
|
$this->mergeFilesystem = MergeFilesystem::instance([ |
|
31
|
|
|
'disk' => $settings->mergeDisk(), |
|
32
|
|
|
'folder' => $settings->mergeFolder(), |
|
33
|
|
|
]); |
|
34
|
|
|
} |
|
35
|
|
|
|
|
36
|
|
|
private function defaultMergeStrategy() |
|
37
|
|
|
{ |
|
38
|
|
|
return $this->settings->defaultMergeStrategy(); |
|
39
|
|
|
} |
|
40
|
|
|
|
|
41
|
|
|
public function setStrategy($strategy = null): MergeManager |
|
42
|
|
|
{ |
|
43
|
|
|
if ($strategy instanceof MergeStrategy) { |
|
44
|
|
|
$this->strategy = $strategy; |
|
|
|
|
|
|
45
|
|
|
} elseif ($strategy === null) { |
|
46
|
|
|
$this->defaultMergeStrategy(); |
|
47
|
|
|
} |
|
48
|
|
|
|
|
49
|
|
|
return $this; |
|
50
|
|
|
} |
|
51
|
|
|
|
|
52
|
|
|
/** |
|
53
|
|
|
* {@inheritdoc} |
|
54
|
|
|
*/ |
|
55
|
|
|
public function mergeFilesystem(): MergeFilesystem |
|
56
|
|
|
{ |
|
57
|
|
|
return $this->mergeFilesystem; |
|
58
|
|
|
} |
|
59
|
|
|
|
|
60
|
|
|
/** |
|
61
|
|
|
* {@inheritdoc} |
|
62
|
|
|
*/ |
|
63
|
|
|
public function getMergeDisk(): ?string |
|
64
|
|
|
{ |
|
65
|
|
|
return $this->settings |
|
66
|
|
|
->mergeDisk(); |
|
67
|
|
|
} |
|
68
|
|
|
|
|
69
|
|
|
/** |
|
70
|
|
|
* {@inheritdoc} |
|
71
|
|
|
*/ |
|
72
|
|
|
public function getMergeFolder(): string |
|
73
|
|
|
{ |
|
74
|
|
|
return $this->settings |
|
75
|
|
|
->mergeFolder(); |
|
76
|
|
|
} |
|
77
|
|
|
|
|
78
|
|
|
/** |
|
79
|
|
|
* {@inheritdoc} |
|
80
|
|
|
*/ |
|
81
|
|
|
public function getMergeOptions(): array |
|
82
|
|
|
{ |
|
83
|
|
|
return array_merge([ |
|
84
|
|
|
'disk' => $this->getMergeDisk(), |
|
85
|
|
|
], $this->settings->additionalMergeOptions()); |
|
86
|
|
|
} |
|
87
|
|
|
|
|
88
|
|
|
/** |
|
89
|
|
|
* {@inheritdoc} |
|
90
|
|
|
*/ |
|
91
|
|
|
public function store(string $destination, $origin, $options = []) |
|
92
|
|
|
{ |
|
93
|
|
|
return $this->mergeFilesystem->store($destination, $origin, $options); |
|
94
|
|
|
} |
|
95
|
|
|
|
|
96
|
|
|
/** |
|
97
|
|
|
* {@inheritdoc} |
|
98
|
|
|
*/ |
|
99
|
|
|
public function destinationPath(string $path): string |
|
100
|
|
|
{ |
|
101
|
|
|
return $this->mergeFilesystem()->destinationPath($path); |
|
102
|
|
|
} |
|
103
|
|
|
|
|
104
|
|
|
public static function getInstance(): MergeManager |
|
105
|
|
|
{ |
|
106
|
|
|
if (static::$instance === null) { |
|
|
|
|
|
|
107
|
|
|
static::$instance = Container::getInstance()->make(MergeManagerContract::class); |
|
108
|
|
|
} |
|
109
|
|
|
|
|
110
|
|
|
return static::$instance; |
|
|
|
|
|
|
111
|
|
|
} |
|
112
|
|
|
} |
|
113
|
|
|
|
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths