Skip to content

Commit

Permalink
ConstantsAware: added hasConstant() (#133)
Browse files Browse the repository at this point in the history
  • Loading branch information
sanderdlm authored and dg committed Jul 30, 2023
1 parent b2aebf0 commit 3fc3fcc
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/PhpGenerator/Traits/ConstantsAware.php
Original file line number Diff line number Diff line change
Expand Up @@ -62,4 +62,10 @@ public function removeConstant(string $name): static
unset($this->consts[$name]);
return $this;
}


public function hasConstant(string $name): bool
{
return isset($this->consts[$name]);
}
}
2 changes: 2 additions & 0 deletions tests/PhpGenerator/ClassType.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@ $class->addConstant('ROLE', 'admin');
$class->addConstant('ACTIVE', false)
->setFinal()
->setType('bool');
Assert::true($class->hasConstant('ROLE'));
Assert::false($class->hasConstant('xxx'));

Assert::false($class->isFinal());
Assert::true($class->isAbstract());
Expand Down

0 comments on commit 3fc3fcc

Please sign in to comment.