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