Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
Total | |
0.00% |
0 / 17 |
|
0.00% |
0 / 5 |
CRAP | |
0.00% |
0 / 1 |
MediaWikiConfigBuilder | |
0.00% |
0 / 17 |
|
0.00% |
0 / 5 |
42 | |
0.00% |
0 / 1 |
__construct | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
getDependenciesPaths | |
0.00% |
0 / 7 |
|
0.00% |
0 / 1 |
6 | |||
addExtensionDependencies | |
0.00% |
0 / 4 |
|
0.00% |
0 / 1 |
2 | |||
addSkinDependencies | |
0.00% |
0 / 4 |
|
0.00% |
0 / 1 |
2 | |||
getTaintCheckPluginName | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 |
1 | <?php |
2 | /** @noinspection PhpUnused */ |
3 | |
4 | namespace MediaWikiPhanConfig; |
5 | |
6 | class MediaWikiConfigBuilder extends ConfigBuilder { |
7 | /** @var string */ |
8 | private string $installPath; |
9 | |
10 | /** |
11 | * @param string $installPath |
12 | */ |
13 | public function __construct( string $installPath ) { |
14 | $this->installPath = rtrim( $installPath, '/' ); |
15 | } |
16 | |
17 | /** |
18 | * @param string[] $names |
19 | * @param string $type 'extension' or 'skin' |
20 | * @return string[] |
21 | */ |
22 | private function getDependenciesPaths( array $names, string $type ): array { |
23 | return array_map( |
24 | function ( string $name ) use ( $type ): string { |
25 | $dir = $type === 'extension' ? 'extensions' : 'skins'; |
26 | return $this->installPath . "/$dir/$name"; |
27 | }, |
28 | $names |
29 | ); |
30 | } |
31 | |
32 | /** |
33 | * @todo Exclude multiple vendor directories |
34 | * @param string ...$extensions |
35 | * @return $this |
36 | */ |
37 | public function addExtensionDependencies( string ...$extensions ): self { |
38 | $extDirs = $this->getDependenciesPaths( $extensions, 'extension' ); |
39 | $this->addDirectories( ...$extDirs ); |
40 | $this->excludeDirectories( ...$extDirs ); |
41 | return $this; |
42 | } |
43 | |
44 | /** |
45 | * @todo Exclude multiple vendor directories |
46 | * @param string ...$skins |
47 | * @return $this |
48 | */ |
49 | public function addSkinDependencies( string ...$skins ): self { |
50 | $skinDirs = $this->getDependenciesPaths( $skins, 'skin' ); |
51 | $this->addDirectories( ...$skinDirs ); |
52 | $this->excludeDirectories( ...$skinDirs ); |
53 | return $this; |
54 | } |
55 | |
56 | protected function getTaintCheckPluginName(): string { |
57 | return 'MediaWikiSecurityCheckPlugin'; |
58 | } |
59 | } |