Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
Total | |
0.00% |
0 / 17 |
|
0.00% |
0 / 17 |
CRAP | |
0.00% |
0 / 1 |
File | |
0.00% |
0 / 17 |
|
0.00% |
0 / 17 |
342 | |
0.00% |
0 / 1 |
__construct | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
getSourcePath | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
isPhpFile | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
setDoCopy | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
isDoCopy | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
setDoPrefix | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
isDoPrefix | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
setDoDelete | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
isDoDelete | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
setDidDelete | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
getDidDelete | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
addDiscoveredSymbol | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
getDiscoveredSymbols | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
setAbsoluteTargetPath | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
getAbsoluteTargetPath | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
6 | |||
setDidUpdate | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
getDidUpdate | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 |
1 | <?php |
2 | /** |
3 | * A file without a dependency means the project src files and the vendor/composer autoload files. |
4 | */ |
5 | |
6 | namespace BrianHenryIE\Strauss\Files; |
7 | |
8 | use BrianHenryIE\Strauss\Types\DiscoveredSymbol; |
9 | |
10 | class File implements FileBase |
11 | { |
12 | /** |
13 | * @var string The absolute path to the file on disk. |
14 | */ |
15 | protected string $sourceAbsolutePath; |
16 | |
17 | /** |
18 | * Should this file be copied to the target directory? |
19 | */ |
20 | protected bool $doCopy = true; |
21 | |
22 | /** |
23 | * Should this file be deleted from the source directory? |
24 | */ |
25 | protected bool $doDelete = false; |
26 | |
27 | /** @var DiscoveredSymbol[] */ |
28 | protected array $discoveredSymbols = []; |
29 | |
30 | protected string $absoluteTargetPath; |
31 | |
32 | protected bool $didDelete = false; |
33 | |
34 | public function __construct(string $sourceAbsolutePath) |
35 | { |
36 | $this->sourceAbsolutePath = $sourceAbsolutePath; |
37 | } |
38 | |
39 | public function getSourcePath(): string |
40 | { |
41 | return $this->sourceAbsolutePath; |
42 | } |
43 | |
44 | public function isPhpFile(): bool |
45 | { |
46 | return substr($this->sourceAbsolutePath, -4) === '.php'; |
47 | } |
48 | |
49 | /** |
50 | * Some combination of file copy exclusions and vendor-dir == target-dir |
51 | * |
52 | * @param bool $doCopy |
53 | * |
54 | * @return void |
55 | */ |
56 | public function setDoCopy(bool $doCopy): void |
57 | { |
58 | $this->doCopy = $doCopy; |
59 | } |
60 | public function isDoCopy(): bool |
61 | { |
62 | return $this->doCopy; |
63 | } |
64 | |
65 | public function setDoPrefix(bool $doPrefix): void |
66 | { |
67 | } |
68 | |
69 | /** |
70 | * Is this correct? Is there ever a time that NO changes should be made to a file? I.e. another file would have its |
71 | * namespace changed and it needs to be updated throughout. |
72 | * |
73 | * Is this really a Symbol level function? |
74 | */ |
75 | public function isDoPrefix(): bool |
76 | { |
77 | return true; |
78 | } |
79 | |
80 | /** |
81 | * Used to mark files that are symlinked as not-to-be-deleted. |
82 | * |
83 | * @param bool $doDelete |
84 | */ |
85 | public function setDoDelete(bool $doDelete): void |
86 | { |
87 | $this->doDelete = $doDelete; |
88 | } |
89 | |
90 | /** |
91 | * Should file be deleted? |
92 | * |
93 | * NB: Also respect the "delete_vendor_files"|"delete_vendor_packages" settings. |
94 | */ |
95 | public function isDoDelete(): bool |
96 | { |
97 | return $this->doDelete; |
98 | } |
99 | |
100 | public function setDidDelete(bool $didDelete): void |
101 | { |
102 | $this->didDelete = $didDelete; |
103 | } |
104 | public function getDidDelete(): bool |
105 | { |
106 | return $this->didDelete; |
107 | } |
108 | |
109 | public function addDiscoveredSymbol(DiscoveredSymbol $symbol): void |
110 | { |
111 | $this->discoveredSymbols[$symbol->getOriginalSymbol()] = $symbol; |
112 | } |
113 | |
114 | /** |
115 | * @return array<string, DiscoveredSymbol> The discovered symbols in the file, indexed by their original string name. |
116 | */ |
117 | public function getDiscoveredSymbols(): array |
118 | { |
119 | return $this->discoveredSymbols; |
120 | } |
121 | |
122 | public function setAbsoluteTargetPath(string $absoluteTargetPath): void |
123 | { |
124 | $this->absoluteTargetPath = $absoluteTargetPath; |
125 | } |
126 | |
127 | /** |
128 | * The target path to (maybe) copy the file to, and the target path to perform replacements in (which may be the |
129 | * original path). |
130 | */ |
131 | public function getAbsoluteTargetPath(): string |
132 | { |
133 | // TODO: Maybe this is a mistake and should better be an exception. |
134 | return isset($this->absoluteTargetPath) ? $this->absoluteTargetPath : $this->sourceAbsolutePath; |
135 | } |
136 | |
137 | protected bool $didUpdate = false; |
138 | public function setDidUpdate(): void |
139 | { |
140 | $this->didUpdate = true; |
141 | } |
142 | public function getDidUpdate(): bool |
143 | { |
144 | return $this->didUpdate; |
145 | } |
146 | } |