12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485 |
- <?php
- declare(strict_types=1);
- namespace PhpParser\Builder;
- use PhpParser;
- use PhpParser\BuilderHelpers;
- use PhpParser\Node;
- use PhpParser\Node\Identifier;
- use PhpParser\Node\Stmt;
- class EnumCase implements PhpParser\Builder
- {
- protected $name;
- protected $value = null;
- protected $attributes = [];
-
- protected $attributeGroups = [];
-
- public function __construct($name) {
- $this->name = $name;
- }
-
- public function setValue($value) {
- $this->value = BuilderHelpers::normalizeValue($value);
- return $this;
- }
-
- public function setDocComment($docComment) {
- $this->attributes = [
- 'comments' => [BuilderHelpers::normalizeDocComment($docComment)]
- ];
- return $this;
- }
-
- public function addAttribute($attribute) {
- $this->attributeGroups[] = BuilderHelpers::normalizeAttribute($attribute);
- return $this;
- }
-
- public function getNode(): PhpParser\Node {
- return new Stmt\EnumCase(
- $this->name,
- $this->value,
- $this->attributeGroups,
- $this->attributes
- );
- }
- }
|