Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
100.00% covered (success)
100.00%
20 / 20
100.00% covered (success)
100.00%
11 / 11
CRAP
100.00% covered (success)
100.00%
1 / 1
ModuleInfo
100.00% covered (success)
100.00%
20 / 20
100.00% covered (success)
100.00%
11 / 11
11
100.00% covered (success)
100.00%
1 / 1
 __construct
100.00% covered (success)
100.00%
10 / 10
100.00% covered (success)
100.00%
1 / 1
1
 getId
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 getAvailability
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 isExternal
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 getTitle
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 getDescription
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 getVersion
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 getLocalDescriptionSpecPath
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 getGroups
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 getExternalBaseUrl
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 getExternalSpecUrl
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
1<?php
2
3namespace MediaWiki\Rest\Module;
4
5/**
6 * Encapsulates resolved information about a REST module.
7 *
8 * @since 1.47
9 */
10class ModuleInfo {
11    private string $id;
12    private ModuleMode $availability;
13    private bool $isExternal;
14    private ?string $title;
15    private ?string $description;
16    private ?string $version;
17    private ?string $localSpecPath;
18    private array $groups;
19    private ?string $externalBaseUrl;
20    private ?string $externalSpecUrl;
21
22    /**
23     * @param string $id The module ID (e.g., 'site/v1' or '' for prefix-less)
24     * @param ModuleMode $availability The module availability
25     * @param bool $isExternal Whether the module is external or local
26     * @param ?string $title The display name of the module
27     * @param ?string $description The description of the module
28     * @param ?string $version The version string
29     * @param ?string $oadSpecPath Module-relative OAD spec path (e.g. '/openapi.json'), or, null
30     * @param string[] $groups The audience designation groups
31     * @param ?string $externalBaseUrl The external base URL, or null for local modules
32     * @param ?string $externalSpecUrl The external spec URL, or null for local modules
33     */
34    public function __construct(
35        string $id,
36        ModuleMode $availability,
37        bool $isExternal,
38        ?string $title,
39        ?string $description,
40        ?string $version,
41        ?string $oadSpecPath,
42        array $groups,
43        ?string $externalBaseUrl = null,
44        ?string $externalSpecUrl = null
45    ) {
46        $this->id = $id;
47        $this->availability = $availability;
48        $this->isExternal = $isExternal;
49        $this->title = $title;
50        $this->description = $description;
51        $this->version = $version;
52        $this->localSpecPath = $oadSpecPath;
53        $this->groups = $groups;
54        $this->externalBaseUrl = $externalBaseUrl;
55        $this->externalSpecUrl = $externalSpecUrl;
56    }
57
58    public function getId(): string {
59        return $this->id;
60    }
61
62    public function getAvailability(): ModuleMode {
63        return $this->availability;
64    }
65
66    public function isExternal(): bool {
67        return $this->isExternal;
68    }
69
70    public function getTitle(): ?string {
71        return $this->title;
72    }
73
74    public function getDescription(): ?string {
75        return $this->description;
76    }
77
78    public function getVersion(): ?string {
79        return $this->version;
80    }
81
82    /**
83     * Gets the relative path to the module's OpenAPI OAD spec.
84     *
85     * Null for external modules or local modules using the default generated description.
86     *
87     * @return string|null
88     */
89    public function getLocalDescriptionSpecPath(): ?string {
90        return $this->localSpecPath;
91    }
92
93    /**
94     * @return string[]
95     */
96    public function getGroups(): array {
97        return $this->groups;
98    }
99
100    /**
101     * Gets the configured base URL for an external module.
102     *
103     * Null for local modules.
104     *
105     * @return string|null
106     */
107    public function getExternalBaseUrl(): ?string {
108        return $this->externalBaseUrl;
109    }
110
111    /**
112     * Gets the configured spec URL for an external module.
113     *
114     * Null for local modules.
115     *
116     * @return string|null
117     */
118    public function getExternalSpecUrl(): ?string {
119        return $this->externalSpecUrl;
120    }
121}