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