1
|
|
|
<?php |
2
|
|
|
declare(strict_types=1); |
3
|
|
|
|
4
|
|
|
/** |
5
|
|
|
* This file is part of phpDocumentor. |
6
|
|
|
* |
7
|
|
|
* For the full copyright and license information, please view the LICENSE |
8
|
|
|
* file that was distributed with this source code. |
9
|
|
|
* |
10
|
|
|
* @author Mike van Riel <[email protected]> |
11
|
|
|
* @copyright 2010-2018 Mike van Riel / Naenius (http://www.naenius.com) |
12
|
|
|
* @license http://www.opensource.org/licenses/mit-license.php MIT |
13
|
|
|
* @link http://phpdoc.org |
14
|
|
|
*/ |
15
|
|
|
|
16
|
|
|
namespace phpDocumentor\Descriptor; |
17
|
|
|
|
18
|
|
|
use phpDocumentor\Descriptor\ProjectDescriptor\Settings; |
19
|
|
|
|
20
|
|
|
/** |
21
|
|
|
* Represents the entire project with its files, namespaces and indexes. |
22
|
|
|
*/ |
23
|
|
|
class ProjectDescriptor implements Interfaces\ProjectInterface, Descriptor |
24
|
|
|
{ |
25
|
|
|
/** @var string $name */ |
26
|
|
|
protected $name = ''; |
27
|
|
|
|
28
|
|
|
/** @var NamespaceDescriptor $namespace */ |
29
|
|
|
protected $namespace; |
30
|
|
|
|
31
|
|
|
/** @var Collection $files */ |
32
|
|
|
protected $files; |
33
|
|
|
|
34
|
|
|
/** @var Collection $indexes */ |
35
|
|
|
protected $indexes; |
36
|
|
|
|
37
|
|
|
/** @var Settings $settings */ |
38
|
|
|
protected $settings; |
39
|
|
|
|
40
|
|
|
/** @var Collection $partials */ |
41
|
|
|
protected $partials; |
42
|
|
|
|
43
|
|
|
/** |
44
|
|
|
* Initializes this descriptor. |
45
|
|
|
*/ |
46
|
7 |
|
public function __construct($name) |
47
|
|
|
{ |
48
|
7 |
|
$this->setName($name); |
49
|
7 |
|
$this->setSettings(new Settings()); |
50
|
|
|
|
51
|
7 |
|
$namespace = new NamespaceDescriptor(); |
52
|
7 |
|
$namespace->setName('\\'); |
53
|
7 |
|
$namespace->setFullyQualifiedStructuralElementName('\\'); |
54
|
7 |
|
$this->setNamespace($namespace); |
55
|
|
|
|
56
|
7 |
|
$this->setFiles(new Collection()); |
57
|
7 |
|
$this->setIndexes(new Collection()); |
58
|
|
|
|
59
|
7 |
|
$this->setPartials(new Collection()); |
60
|
7 |
|
} |
61
|
|
|
|
62
|
|
|
/** |
63
|
|
|
* Sets the name for this project. |
64
|
|
|
* |
65
|
|
|
* @param string $name |
66
|
|
|
*/ |
67
|
2 |
|
public function setName($name) |
68
|
|
|
{ |
69
|
2 |
|
$this->name = $name; |
70
|
2 |
|
} |
71
|
|
|
|
72
|
|
|
/** |
73
|
|
|
* Returns the name of this project. |
74
|
|
|
* |
75
|
|
|
* @return string |
76
|
|
|
*/ |
77
|
1 |
|
public function getName() |
78
|
|
|
{ |
79
|
1 |
|
return $this->name; |
80
|
|
|
} |
81
|
|
|
|
82
|
|
|
/** |
83
|
|
|
* Returns the description for this element. |
84
|
|
|
* |
85
|
|
|
* @return string |
86
|
|
|
*/ |
87
|
2 |
|
public function getDescription() |
88
|
|
|
{ |
89
|
2 |
|
return ''; |
90
|
2 |
|
} |
91
|
|
|
|
92
|
|
|
/** |
93
|
|
|
* Sets all files on this project. |
94
|
|
|
* |
95
|
|
|
* @param Collection $files |
96
|
|
|
*/ |
97
|
2 |
|
public function setFiles($files) |
98
|
|
|
{ |
99
|
2 |
|
$this->files = $files; |
100
|
|
|
} |
101
|
|
|
|
102
|
|
|
/** |
103
|
|
|
* Returns all files with their sub-elements. |
104
|
|
|
* |
105
|
|
|
* @return Collection|FileDescriptor[] |
106
|
|
|
*/ |
107
|
|
|
public function getFiles() |
108
|
|
|
{ |
109
|
2 |
|
return $this->files; |
110
|
|
|
} |
111
|
2 |
|
|
112
|
2 |
|
/** |
113
|
|
|
* Sets all indexes for this project. |
114
|
|
|
* |
115
|
|
|
* An index is a compilation of references to elements, usually constructed in a compiler step, that aids template |
116
|
|
|
* generation by providing a conveniently assembled list. An example of such an index is the 'marker' index where |
117
|
|
|
* a list of TODOs and FIXMEs are located in a central location for reporting. |
118
|
|
|
*/ |
119
|
|
|
public function setIndexes(Collection $indexes) |
120
|
|
|
{ |
121
|
1 |
|
$this->indexes = $indexes; |
122
|
|
|
} |
123
|
1 |
|
|
124
|
|
|
/** |
125
|
|
|
* Returns all indexes in this project. |
126
|
|
|
* |
127
|
|
|
* @see setIndexes() for more information on what indexes are. |
128
|
|
|
* |
129
|
|
|
* @return Collection |
130
|
|
|
*/ |
131
|
2 |
|
public function getIndexes() |
132
|
|
|
{ |
133
|
2 |
|
return $this->indexes; |
134
|
2 |
|
} |
135
|
|
|
|
136
|
|
|
/** |
137
|
|
|
* Sets the root namespace for this project together with all sub-namespaces. |
138
|
|
|
* |
139
|
|
|
* @param NamespaceDescriptor $namespace |
140
|
|
|
*/ |
141
|
1 |
|
public function setNamespace($namespace) |
142
|
|
|
{ |
143
|
1 |
|
$this->namespace = $namespace; |
144
|
|
|
} |
145
|
|
|
|
146
|
|
|
/** |
147
|
|
|
* Returns the root (global) namespace. |
148
|
|
|
* |
149
|
|
|
* @return NamespaceDescriptor |
150
|
|
|
*/ |
151
|
2 |
|
public function getNamespace() |
152
|
|
|
{ |
153
|
2 |
|
return $this->namespace; |
154
|
2 |
|
} |
155
|
|
|
|
156
|
|
|
/** |
157
|
|
|
* Sets the settings used to build the documentation for this project. |
158
|
|
|
* |
159
|
|
|
* @param Settings $settings |
160
|
|
|
*/ |
161
|
2 |
|
public function setSettings($settings) |
162
|
|
|
{ |
163
|
2 |
|
$this->settings = $settings; |
164
|
|
|
} |
165
|
|
|
|
166
|
|
|
/** |
167
|
|
|
* Returns the settings used to build the documentation for this project. |
168
|
|
|
* |
169
|
|
|
* @return Settings |
170
|
|
|
*/ |
171
|
|
|
public function getSettings() |
172
|
2 |
|
{ |
173
|
|
|
return $this->settings; |
174
|
2 |
|
} |
175
|
2 |
|
|
176
|
|
|
/** |
177
|
|
|
* Sets all partials that can be used in a template. |
178
|
|
|
* |
179
|
|
|
* Partials are blocks of text that can be inserted anywhere in a template using a special indicator. An example is |
180
|
|
|
* the introduction partial that can add a custom piece of text to the homepage. |
181
|
|
|
*/ |
182
|
|
|
public function setPartials(Collection $partials) |
183
|
|
|
{ |
184
|
1 |
|
$this->partials = $partials; |
185
|
|
|
} |
186
|
1 |
|
|
187
|
|
|
/** |
188
|
|
|
* Returns a list of all partials. |
189
|
|
|
* |
190
|
|
|
* @see setPartials() for more information on partials. |
191
|
|
|
* |
192
|
|
|
* @return Collection |
193
|
|
|
*/ |
194
|
|
|
public function getPartials() |
195
|
|
|
{ |
196
|
|
|
return $this->partials; |
197
|
|
|
} |
198
|
1 |
|
|
199
|
|
|
/** |
200
|
1 |
|
* Checks whether the Project supports the given visibility. |
201
|
1 |
|
* |
202
|
1 |
|
* @param integer $visibility One of the VISIBILITY_* constants of the Settings class. |
203
|
|
|
* |
204
|
1 |
|
* @see Settings for a list of the available VISIBILITY_* constants. |
205
|
|
|
* |
206
|
|
|
* @return boolean |
207
|
|
|
*/ |
208
|
|
|
public function isVisibilityAllowed($visibility) |
209
|
|
|
{ |
210
|
|
|
$visibilityAllowed = $this->getSettings() |
211
|
|
|
? $this->getSettings()->getVisibility() |
212
|
|
|
: Settings::VISIBILITY_DEFAULT; |
213
|
|
|
|
214
|
|
|
return (bool) ($visibilityAllowed & $visibility); |
215
|
|
|
} |
216
|
|
|
} |
217
|
|
|
|