Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
Total | |
100.00% |
16 / 16 |
|
100.00% |
8 / 8 |
CRAP | |
100.00% |
1 / 1 |
TitleNamespace | |
100.00% |
16 / 16 |
|
100.00% |
8 / 8 |
8 | |
100.00% |
1 / 1 |
__construct | |
100.00% |
9 / 9 |
|
100.00% |
1 / 1 |
1 | |||
getId | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
isATalkNamespace | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
isUser | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
isUserTalk | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
isMedia | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
isFile | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
isCategory | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 |
1 | <?php |
2 | declare( strict_types = 1 ); |
3 | |
4 | namespace Wikimedia\Parsoid\Utils; |
5 | |
6 | use Wikimedia\Parsoid\Config\SiteConfig; |
7 | |
8 | /** |
9 | * @deprecated Use namespace IDs and SiteConfig methods instead. |
10 | */ |
11 | class TitleNamespace { |
12 | |
13 | /** @var int */ |
14 | private $id; |
15 | |
16 | /** @phan-var array<string,bool> */ |
17 | private $is; |
18 | |
19 | /** |
20 | * @param int $id |
21 | * @param SiteConfig $siteConfig |
22 | */ |
23 | public function __construct( int $id, SiteConfig $siteConfig ) { |
24 | $this->id = $id; |
25 | $this->is = [ |
26 | 'a talk' => $siteConfig->namespaceIsTalk( $id ), |
27 | 'user' => $id === $siteConfig->canonicalNamespaceId( 'user' ), |
28 | 'user_talk' => $id === $siteConfig->canonicalNamespaceId( 'user_talk' ), |
29 | 'media' => $id === $siteConfig->canonicalNamespaceId( 'media' ), |
30 | 'file' => $id === $siteConfig->canonicalNamespaceId( 'file' ), |
31 | 'category' => $id === $siteConfig->canonicalNamespaceId( 'category' ), |
32 | ]; |
33 | } |
34 | |
35 | /** |
36 | * Get the ID |
37 | * @return int |
38 | */ |
39 | public function getId(): int { |
40 | return $this->id; |
41 | } |
42 | |
43 | public function isATalkNamespace(): bool { |
44 | return $this->is['a talk']; |
45 | } |
46 | |
47 | public function isUser(): bool { |
48 | return $this->is['user']; |
49 | } |
50 | |
51 | public function isUserTalk(): bool { |
52 | return $this->is['user_talk']; |
53 | } |
54 | |
55 | public function isMedia(): bool { |
56 | return $this->is['media']; |
57 | } |
58 | |
59 | public function isFile(): bool { |
60 | return $this->is['file']; |
61 | } |
62 | |
63 | public function isCategory(): bool { |
64 | return $this->is['category']; |
65 | } |
66 | |
67 | } |