Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
Total | |
0.00% |
0 / 12 |
|
0.00% |
0 / 7 |
CRAP | |
0.00% |
0 / 1 |
Tab | |
0.00% |
0 / 12 |
|
0.00% |
0 / 7 |
56 | |
0.00% |
0 / 1 |
__construct | |
0.00% |
0 / 6 |
|
0.00% |
0 / 1 |
2 | |||
getId | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
getName | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
getLabel | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
getContent | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
isSelected | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
isDisabled | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 |
1 | <?php |
2 | /** |
3 | * Tab.php |
4 | * |
5 | * This file is part of the Codex design system, the official design system for Wikimedia projects. |
6 | * It contains the definition and implementation of the `Tab` class, responsible for managing |
7 | * the behavior and properties of the corresponding component. |
8 | * |
9 | * @category Component |
10 | * @package Codex\Component |
11 | * @since 0.1.0 |
12 | * @author Doğu Abaris <abaris@null.net> |
13 | * @license https://www.gnu.org/copyleft/gpl.html GPL-2.0-or-later |
14 | * @link https://doc.wikimedia.org/codex/main/ Codex Documentation |
15 | */ |
16 | |
17 | namespace Wikimedia\Codex\Component; |
18 | |
19 | /** |
20 | * Tab |
21 | * |
22 | * This class is part of the Codex PHP library and is responsible for |
23 | * representing an immutable object. It is primarily intended for use |
24 | * with a builder class to construct its instances. |
25 | * |
26 | * @category Component |
27 | * @package Codex\Component |
28 | * @since 0.1.0 |
29 | * @author Doğu Abaris <abaris@null.net> |
30 | * @license https://www.gnu.org/copyleft/gpl.html GPL-2.0-or-later |
31 | * @link https://doc.wikimedia.org/codex/main/ Codex Documentation |
32 | */ |
33 | class Tab { |
34 | |
35 | /** |
36 | * The ID for the tab. |
37 | */ |
38 | private string $id; |
39 | |
40 | /** |
41 | * The unique name of the tab, used for programmatic selection. |
42 | */ |
43 | private string $name; |
44 | |
45 | /** |
46 | * The text label displayed for the tab in the Tabs component's header. |
47 | */ |
48 | private string $label; |
49 | |
50 | /** |
51 | * The HTML content associated with the tab, displayed when the tab is selected. |
52 | */ |
53 | private string $content; |
54 | |
55 | /** |
56 | * Indicates whether the tab is selected by default. |
57 | */ |
58 | private bool $selected; |
59 | |
60 | /** |
61 | * Indicates whether the tab is disabled, preventing interaction and navigation. |
62 | */ |
63 | private bool $disabled; |
64 | |
65 | /** |
66 | * Constructor for the Tab component. |
67 | * |
68 | * Initializes a Tab instance with the specified properties. |
69 | * |
70 | * @param string $id The ID for the tab. |
71 | * @param string $name The unique name of the tab. |
72 | * @param string $label The label of the tab. |
73 | * @param string $content The content of the tab. |
74 | * @param bool $selected Whether the tab is selected by default. |
75 | * @param bool $disabled Whether the tab is disabled. |
76 | */ |
77 | public function __construct( |
78 | string $id, |
79 | string $name, |
80 | string $label, |
81 | string $content, |
82 | bool $selected, |
83 | bool $disabled |
84 | ) { |
85 | $this->id = $id; |
86 | $this->name = $name; |
87 | $this->label = $label; |
88 | $this->content = $content; |
89 | $this->selected = $selected; |
90 | $this->disabled = $disabled; |
91 | } |
92 | |
93 | /** |
94 | * Get the Tab's HTML ID attribute. |
95 | * |
96 | * This method returns the ID assigned to the tab element, which is used |
97 | * for identifying the tab in the HTML document. |
98 | * |
99 | * @since 0.1.0 |
100 | * @return string The ID of the Tab element. |
101 | */ |
102 | public function getId(): string { |
103 | return $this->id; |
104 | } |
105 | |
106 | /** |
107 | * Get the tab's name. |
108 | * |
109 | * @since 0.1.0 |
110 | * @return string The unique name of the tab. |
111 | */ |
112 | public function getName(): string { |
113 | return $this->name; |
114 | } |
115 | |
116 | /** |
117 | * Get the tab's label. |
118 | * |
119 | * @since 0.1.0 |
120 | * @return string The label of the tab. |
121 | */ |
122 | public function getLabel(): string { |
123 | return $this->label; |
124 | } |
125 | |
126 | /** |
127 | * Get the tab's content. |
128 | * |
129 | * @since 0.1.0 |
130 | * @return string The content of the tab. |
131 | */ |
132 | public function getContent(): string { |
133 | return $this->content; |
134 | } |
135 | |
136 | /** |
137 | * Get the tab's selected state. |
138 | * |
139 | * @since 0.1.0 |
140 | * @return bool Whether the tab is selected. |
141 | */ |
142 | public function isSelected(): bool { |
143 | return $this->selected; |
144 | } |
145 | |
146 | /** |
147 | * Get the tab's disabled state. |
148 | * |
149 | * @since 0.1.0 |
150 | * @return bool Whether the tab is disabled. |
151 | */ |
152 | public function isDisabled(): bool { |
153 | return $this->disabled; |
154 | } |
155 | } |