Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
Total | |
100.00% |
13 / 13 |
|
100.00% |
2 / 2 |
CRAP | |
100.00% |
1 / 1 |
LocalSourceEntityNamespacesFactory | |
100.00% |
13 / 13 |
|
100.00% |
2 / 2 |
2 | |
100.00% |
1 / 1 |
__construct | |
100.00% |
2 / 2 |
|
100.00% |
1 / 1 |
1 | |||
getEntityNamespaces | |
100.00% |
11 / 11 |
|
100.00% |
1 / 1 |
1 |
1 | <?php |
2 | |
3 | namespace MediaWiki\Extension\WikibaseManifest; |
4 | |
5 | use NamespaceInfo; |
6 | use Wikibase\DataAccess\DatabaseEntitySource; |
7 | |
8 | class LocalSourceEntityNamespacesFactory implements EntityNamespacesFactory { |
9 | private $localEntitySource; |
10 | private $namespaceInfo; |
11 | |
12 | public function __construct( DatabaseEntitySource $localEntitySource, NamespaceInfo $namespaceInfo ) { |
13 | $this->localEntitySource = $localEntitySource; |
14 | $this->namespaceInfo = $namespaceInfo; |
15 | } |
16 | |
17 | public function getEntityNamespaces(): EntityNamespaces { |
18 | $entityNamespaceMapping = array_map( |
19 | function ( $x ) { |
20 | return [ |
21 | EntityNamespaces::NAMESPACE_ID => $x, |
22 | EntityNamespaces::NAMESPACE_NAME => $this->namespaceInfo->getCanonicalName( |
23 | $x ) |
24 | ]; |
25 | }, |
26 | $this->localEntitySource->getEntityNamespaceIds() |
27 | ); |
28 | |
29 | return new EntityNamespaces( $entityNamespaceMapping ); |
30 | } |
31 | } |