forked from phpowermove/php-code-generator
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPhpConstant.php
More file actions
68 lines (60 loc) · 1.57 KB
/
PhpConstant.php
File metadata and controls
68 lines (60 loc) · 1.57 KB
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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
<?php
namespace gossi\codegen\model;
use gossi\codegen\model\parts\DocblockPart;
use gossi\codegen\model\parts\LongDescriptionPart;
use gossi\codegen\model\parts\NamePart;
use gossi\codegen\model\parts\TypeDocblockGeneratorPart;
use gossi\codegen\model\parts\TypePart;
use gossi\codegen\model\parts\ValuePart;
use gossi\docblock\Docblock;
use gossi\docblock\tags\VarTag;
/**
* Represents a PHP constant.
*
* @author Thomas Gossmann
*/
class PhpConstant extends AbstractModel implements GenerateableInterface, DocblockInterface, ValueInterface {
use DocblockPart;
use LongDescriptionPart;
use NamePart;
use TypeDocblockGeneratorPart;
use TypePart;
use ValuePart;
/**
* Creates a new PHP constant
*
* @param string $name
* @param mixed $value
* @param bool $isExpression
* @return static
*/
public static function create($name = null, $value = null, $isExpression = false) {
return new static($name, $value, $isExpression);
}
/**
* Creates a new PHP constant
*
* @param string $name
* @param mixed $value
* @param bool $isExpression
*/
public function __construct($name = null, $value = null, $isExpression = false) {
$this->setName($name);
if ($isExpression) {
$this->setExpression($value);
} else {
$this->setValue($value);
}
$this->docblock = new Docblock();
}
/**
* @inheritDoc
*/
public function generateDocblock() {
$docblock = $this->getDocblock();
$docblock->setShortDescription($this->getDescription());
$docblock->setLongDescription($this->getLongDescription());
// var tag
$this->generateTypeTag(new VarTag());
}
}