123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687 |
- <?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 ?Node\Expr $value = null;
-
- protected array $attributes = [];
-
- protected array $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
- );
- }
- }
|