1: <?php
2: namespace Pharborist\Constants;
3:
4: use Pharborist\ParentNode;
5: use Pharborist\Namespaces\NameNode;
6: use Pharborist\ExpressionNode;
7:
8: 9: 10:
11: class ConstantNode extends ParentNode implements ExpressionNode {
12: 13: 14: 15: 16:
17: public static function create($name) {
18: if (is_string($name)) {
19: $name = NameNode::create($name);
20: }
21:
22: $node = new static();
23: $node->addChild($name, 'constantName');
24: return $node;
25: }
26:
27: 28: 29:
30: protected $constantName;
31:
32: 33: 34:
35: public function getConstantName() {
36: return $this->constantName;
37: }
38:
39: 40: 41: 42: 43:
44: public function toUpperCase() {
45: $token = $this->getConstantName()->lastToken();
46: $token->setText(strtoupper($token->getText()));
47: return $this;
48: }
49:
50: 51: 52: 53: 54:
55: public function toLowerCase() {
56: $token = $this->getConstantName()->lastToken();
57: $token->setText(strtolower($token->getText()));
58: return $this;
59: }
60: }
61: