1 | <?php |
||
30 | class ProjectDescriptorBuilder |
||
|
|||
31 | { |
||
32 | /** @var string */ |
||
33 | const DEFAULT_PROJECT_NAME = 'Untitled project'; |
||
34 | |||
35 | /** @var AssemblerFactory $assemblerFactory */ |
||
36 | protected $assemblerFactory; |
||
37 | |||
38 | /** @var Filter $filter */ |
||
39 | protected $filter; |
||
40 | |||
41 | /** @var ProjectDescriptor $project */ |
||
42 | protected $project; |
||
43 | |||
44 | /** @var Translator $translator */ |
||
45 | protected $translator; |
||
46 | private $defaultPackage; |
||
47 | |||
48 | public function __construct(AssemblerFactory $assemblerFactory, Filter $filterManager) |
||
53 | |||
54 | 1 | public function createProjectDescriptor() |
|
58 | |||
59 | 1 | public function setProjectDescriptor(ProjectDescriptor $projectDescriptor) |
|
63 | |||
64 | /** |
||
65 | * Returns the project descriptor that is being built. |
||
66 | * |
||
67 | * @return ProjectDescriptor |
||
68 | */ |
||
69 | 2 | public function getProjectDescriptor() |
|
73 | |||
74 | /** |
||
75 | * Verifies whether the given visibility is allowed to be included in the Descriptors. |
||
76 | * |
||
77 | * This method is used anytime a Descriptor is added to a collection (for example, when adding a Method to a Class) |
||
78 | * to determine whether the visibility of that element is matches what the user has specified when it ran |
||
79 | * phpDocumentor. |
||
80 | * |
||
81 | * @param string|integer $visibility One of the visibility constants of the ProjectDescriptor class or the words |
||
82 | * 'public', 'protected', 'private' or 'internal'. |
||
83 | * |
||
84 | * @see ProjectDescriptor where the visibility is stored and that declares the constants to use. |
||
85 | * |
||
86 | * @return boolean |
||
87 | */ |
||
88 | 1 | public function isVisibilityAllowed($visibility) |
|
89 | { |
||
90 | switch ($visibility) { |
||
91 | 1 | case 'public': |
|
92 | $visibility = Settings::VISIBILITY_PUBLIC; |
||
93 | break; |
||
94 | 1 | case 'protected': |
|
95 | $visibility = Settings::VISIBILITY_PROTECTED; |
||
96 | break; |
||
97 | 1 | case 'private': |
|
98 | $visibility = Settings::VISIBILITY_PRIVATE; |
||
99 | break; |
||
100 | 1 | case 'internal': |
|
101 | $visibility = Settings::VISIBILITY_INTERNAL; |
||
102 | break; |
||
103 | } |
||
104 | |||
105 | 1 | return $this->getProjectDescriptor()->isVisibilityAllowed($visibility); |
|
106 | } |
||
107 | |||
108 | /** |
||
109 | * Takes the given data and attempts to build a Descriptor from it. |
||
110 | * |
||
111 | * @param mixed $data |
||
112 | * |
||
113 | * @throws \InvalidArgumentException if no Assembler could be found that matches the given data. |
||
114 | * |
||
115 | * @return DescriptorAbstract|Collection|null |
||
116 | */ |
||
117 | public function buildDescriptor($data) |
||
142 | |||
143 | /** |
||
144 | * Attempts to find an assembler matching the given data. |
||
145 | * |
||
146 | * @param mixed $data |
||
147 | * |
||
148 | * @return AssemblerAbstract |
||
149 | */ |
||
150 | public function getAssembler($data) |
||
154 | |||
155 | /** |
||
156 | * Analyzes a Descriptor and alters its state based on its state or even removes the descriptor. |
||
157 | * |
||
158 | * @param Filterable $descriptor |
||
159 | * |
||
160 | * @return Filterable |
||
161 | */ |
||
162 | public function filter(Filterable $descriptor) |
||
166 | |||
167 | /** |
||
168 | * Filters each descriptor, validates them, stores the validation results and returns a collection of transmuted |
||
169 | * objects. |
||
170 | * |
||
171 | * @param DescriptorAbstract[] $descriptor |
||
172 | * |
||
173 | * @return Collection |
||
174 | */ |
||
175 | private function filterEachDescriptor($descriptor) |
||
189 | |||
190 | /** |
||
191 | * Filters a descriptor, validates it, stores the validation results and returns the transmuted object or null |
||
192 | * if it is supposed to be removed. |
||
193 | * |
||
194 | * @param DescriptorAbstract $descriptor |
||
195 | * |
||
196 | * @return DescriptorAbstract|null |
||
197 | */ |
||
198 | protected function filterDescriptor($descriptor) |
||
212 | |||
213 | /** |
||
214 | * Map error code to severity. |
||
215 | * |
||
216 | * @param int $code |
||
217 | * |
||
218 | * @return string |
||
219 | */ |
||
220 | protected function mapCodeToSeverity($code) |
||
230 | |||
231 | /** |
||
232 | * @param Translator $translator |
||
233 | * |
||
234 | * @return void |
||
235 | */ |
||
236 | public function setTranslator(Translator $translator) |
||
240 | |||
241 | public function build(Project $project) |
||
265 | |||
266 | /** |
||
267 | * @return string |
||
268 | */ |
||
269 | public function getDefaultPackage() |
||
273 | } |
||
274 |