-
Notifications
You must be signed in to change notification settings - Fork 122
/
Copy pathConstantObject.php
45 lines (34 loc) · 1.09 KB
/
ConstantObject.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
<?php declare(strict_types = 1);
namespace TheSeer\phpDox\Collector;
use TheSeer\fDOM\fDOMElement;
use TheSeer\phpDox\DocBlock\DocBlock;
class ConstantObject {
protected $ctx;
public function __construct(fDOMElement $ctx) {
$this->ctx = $ctx;
$this->setType('{unknown}');
}
public function export() {
return $this->ctx;
}
public function setName($name): void {
$this->ctx->setAttribute('name', $name);
}
public function setValue($value): void {
$this->ctx->setAttribute('value', $value);
}
public function setType($type): void {
$this->ctx->setAttribute('type', $type);
}
public function setConstantReference($const): void {
$this->ctx->setAttribute('constant', $const);
}
public function setDocBlock(DocBlock $docblock): void {
$docNode = $docblock->asDom($this->ctx->ownerDocument);
if ($this->ctx->hasChildNodes()) {
$this->ctx->insertBefore($docblock, $this->ctx->firstChild);
return;
}
$this->ctx->appendChild($docNode);
}
}