1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Jobtech\LaravelChunky\Strategies; |
4
|
|
|
|
5
|
|
|
use Illuminate\Support\Traits\ForwardsCalls; |
6
|
|
|
use Jobtech\LaravelChunky\Contracts\ChunksManager; |
7
|
|
|
use Jobtech\LaravelChunky\Contracts\MergeManager; |
8
|
|
|
use Jobtech\LaravelChunky\Exceptions\StrategyException; |
9
|
|
|
use Jobtech\LaravelChunky\Strategies\Contracts\MergeStrategy as MergeStrategyContract; |
10
|
|
|
|
11
|
|
|
abstract class MergeStrategy implements MergeStrategyContract |
12
|
|
|
{ |
13
|
|
|
use ForwardsCalls; |
14
|
|
|
|
15
|
|
|
/** |
16
|
|
|
* @var string |
17
|
|
|
*/ |
18
|
|
|
protected string $folder; |
19
|
|
|
|
20
|
|
|
/** |
21
|
|
|
* @var string |
22
|
|
|
*/ |
23
|
|
|
protected string $destination; |
24
|
|
|
|
25
|
|
|
/** |
26
|
|
|
* @var \Jobtech\LaravelChunky\Contracts\ChunksManager|null |
27
|
|
|
*/ |
28
|
|
|
protected ?ChunksManager $chunksManager; |
29
|
|
|
|
30
|
|
|
/** |
31
|
|
|
* @var \Jobtech\LaravelChunky\Contracts\MergeManager|null |
32
|
|
|
*/ |
33
|
|
|
protected ?MergeManager $mergeManager; |
34
|
|
|
|
35
|
|
|
/** |
36
|
|
|
* {@inheritdoc} |
37
|
|
|
*/ |
38
|
|
|
public function chunksManager($manager = null): ChunksManager |
39
|
|
|
{ |
40
|
|
|
if ($manager instanceof ChunksManager) { |
41
|
|
|
$this->chunksManager = $manager; |
42
|
|
|
} elseif ($this->chunksManager === null) { |
43
|
|
|
throw new StrategyException('Chunks manager cannot be empty'); |
44
|
|
|
} |
45
|
|
|
|
46
|
|
|
return $this->chunksManager; |
47
|
|
|
} |
48
|
|
|
|
49
|
|
|
/** |
50
|
|
|
* {@inheritdoc} |
51
|
|
|
*/ |
52
|
|
|
public function mergeManager($manager = null): MergeManager |
53
|
|
|
{ |
54
|
|
|
if ($manager instanceof MergeManager) { |
55
|
|
|
$this->mergeManager = $manager; |
56
|
|
|
} elseif ($this->mergeManager === null) { |
57
|
|
|
throw new StrategyException('Merge manager cannot be empty'); |
58
|
|
|
} |
59
|
|
|
|
60
|
|
|
return $this->mergeManager; |
61
|
|
|
} |
62
|
|
|
|
63
|
|
|
/** |
64
|
|
|
* {@inheritdoc} |
65
|
|
|
*/ |
66
|
|
|
public function destination($destination = null): string |
67
|
|
|
{ |
68
|
|
|
if (is_string($destination) && ! empty($destination)) { |
69
|
|
|
$this->destination = $this->mergeManager->destinationPath($destination); |
|
|
|
|
70
|
|
|
} |
71
|
|
|
|
72
|
|
|
return $this->destination; |
73
|
|
|
} |
74
|
|
|
|
75
|
|
|
/** |
76
|
|
|
* {@inheritdoc} |
77
|
|
|
*/ |
78
|
|
|
public function chunksFolder($folder = null): string |
79
|
|
|
{ |
80
|
|
|
if (is_string($folder) && $this->chunksManager->validFolder($folder)) { |
|
|
|
|
81
|
|
|
$this->folder = $folder; |
82
|
|
|
} elseif (empty($this->folder) || ! $this->chunksManager->validFolder($this->folder)) { |
83
|
|
|
throw new StrategyException('Chunks folder cannot be empty'); |
84
|
|
|
} |
85
|
|
|
|
86
|
|
|
return $this->folder; |
87
|
|
|
} |
88
|
|
|
} |
89
|
|
|
|
This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.
This is most likely a typographical error or the method has been renamed.