Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
Total | |
0.00% |
0 / 7 |
|
0.00% |
0 / 5 |
CRAP | |
0.00% |
0 / 1 |
FileWithDependency | |
0.00% |
0 / 7 |
|
0.00% |
0 / 5 |
30 | |
0.00% |
0 / 1 |
__construct | |
0.00% |
0 / 3 |
|
0.00% |
0 / 1 |
2 | |||
getDependency | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
addAutoloader | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
isFilesAutoloaderFile | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
getVendorRelativePath | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 |
1 | <?php |
2 | |
3 | namespace BrianHenryIE\Strauss\Files; |
4 | |
5 | use BrianHenryIE\Strauss\Composer\ComposerPackage; |
6 | |
7 | class FileWithDependency extends File implements HasDependency |
8 | { |
9 | |
10 | /** |
11 | * @var string The path to the file relative to the package root. |
12 | */ |
13 | protected string $vendorRelativePath; |
14 | |
15 | /** |
16 | * The project dependency that this file belongs to. |
17 | */ |
18 | protected ComposerPackage $dependency; |
19 | |
20 | /** |
21 | * @var string[] The autoloader types that this file is included in. |
22 | */ |
23 | protected array $autoloaderTypes = []; |
24 | |
25 | public function __construct(ComposerPackage $dependency, string $vendorRelativePath, string $sourceAbsolutePath) |
26 | { |
27 | parent::__construct($sourceAbsolutePath); |
28 | |
29 | $this->vendorRelativePath = ltrim($vendorRelativePath, '/\\'); |
30 | $this->dependency = $dependency; |
31 | } |
32 | |
33 | public function getDependency(): ComposerPackage |
34 | { |
35 | return $this->dependency; |
36 | } |
37 | |
38 | /** |
39 | * The target path to (maybe) copy the file to, and the target path to perform replacements in (which may be the |
40 | * original path). |
41 | */ |
42 | |
43 | /** |
44 | * Record the autoloader it is found in. Which could be all of them. |
45 | */ |
46 | public function addAutoloader(string $autoloaderType): void |
47 | { |
48 | $this->autoloaderTypes = array_unique(array_merge($this->autoloaderTypes, array($autoloaderType))); |
49 | } |
50 | |
51 | public function isFilesAutoloaderFile(): bool |
52 | { |
53 | return in_array('files', $this->autoloaderTypes, true); |
54 | } |
55 | |
56 | public function getVendorRelativePath(): string |
57 | { |
58 | return $this->vendorRelativePath; |
59 | } |
60 | } |