Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
Total | |
100.00% |
8 / 8 |
|
100.00% |
6 / 6 |
CRAP | |
100.00% |
1 / 1 |
DiscoveredSymbol | |
100.00% |
8 / 8 |
|
100.00% |
6 / 6 |
6 | |
100.00% |
1 / 1 |
__construct | |
100.00% |
3 / 3 |
|
100.00% |
1 / 1 |
1 | |||
getOriginalSymbol | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
getSourceFiles | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
addSourceFile | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
getReplacement | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
setReplacement | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 |
1 | <?php |
2 | /** |
3 | * A namespace, class, interface or trait discovered in the project. |
4 | */ |
5 | |
6 | namespace BrianHenryIE\Strauss\Types; |
7 | |
8 | use BrianHenryIE\Strauss\Files\File; |
9 | use BrianHenryIE\Strauss\Pipeline\FileSymbolScanner; |
10 | |
11 | abstract class DiscoveredSymbol |
12 | { |
13 | /** @var array<File> $sourceFiles */ |
14 | protected array $sourceFiles = []; |
15 | |
16 | protected string $symbol; |
17 | |
18 | protected string $replacement; |
19 | |
20 | /** |
21 | * @param string $symbol The classname / namespace etc. |
22 | * @param File $sourceFile The file it was discovered in. |
23 | */ |
24 | public function __construct(string $symbol, File $sourceFile) |
25 | { |
26 | $this->symbol = $symbol; |
27 | |
28 | $this->addSourceFile($sourceFile); |
29 | $sourceFile->addDiscoveredSymbol($this); |
30 | } |
31 | |
32 | public function getOriginalSymbol(): string |
33 | { |
34 | return $this->symbol; |
35 | } |
36 | |
37 | /** |
38 | * @return File[] |
39 | */ |
40 | public function getSourceFiles(): array |
41 | { |
42 | return $this->sourceFiles; |
43 | } |
44 | |
45 | /** |
46 | * @param File $sourceFile |
47 | * |
48 | * @see FileSymbolScanner |
49 | */ |
50 | public function addSourceFile(File $sourceFile): void |
51 | { |
52 | $this->sourceFiles[$sourceFile->getSourcePath()] = $sourceFile; |
53 | } |
54 | |
55 | public function getReplacement(): string |
56 | { |
57 | return $this->replacement ?? $this->symbol; |
58 | } |
59 | |
60 | public function setReplacement(string $replacement): void |
61 | { |
62 | $this->replacement = $replacement; |
63 | } |
64 | } |