| 1 |
<?php |
| 2 |
/** |
| 3 |
* This file is part of the Peast package |
| 4 |
* |
| 5 |
* (c) Marco Marchiò <[email protected]> |
| 6 |
* |
| 7 |
* For the full copyright and license information refer to the LICENSE file |
| 8 |
* distributed with this source code |
| 9 |
*/ |
| 10 |
namespace Peast\Syntax\Node; |
| 11 |
|
| 12 |
/** |
| 13 |
* Abstract class for literals. |
| 14 |
* |
| 15 |
* @author Marco Marchiò <[email protected]> |
| 16 |
*/ |
| 17 |
abstract class Literal extends Node implements Expression |
| 18 |
{ |
| 19 |
/** |
| 20 |
* Map of node properties |
| 21 |
* |
| 22 |
* @var array |
| 23 |
*/ |
| 24 |
protected $propertiesMap = array( |
| 25 |
"value" => false, |
| 26 |
"raw" => false |
| 27 |
); |
| 28 |
|
| 29 |
/** |
| 30 |
* Node's value |
| 31 |
* |
| 32 |
* @var mixed |
| 33 |
*/ |
| 34 |
protected $value; |
| 35 |
|
| 36 |
/** |
| 37 |
* Node's raw value |
| 38 |
* |
| 39 |
* @var string |
| 40 |
*/ |
| 41 |
protected $raw; |
| 42 |
|
| 43 |
/** |
| 44 |
* Returns node's type |
| 45 |
* |
| 46 |
* @return string |
| 47 |
*/ |
| 48 |
public function getType() |
| 49 |
{ |
| 50 |
return "Literal"; |
| 51 |
} |
| 52 |
|
| 53 |
/** |
| 54 |
* Returns node's value |
| 55 |
* |
| 56 |
* @return mixed |
| 57 |
*/ |
| 58 |
public function getValue() |
| 59 |
{ |
| 60 |
return $this->value; |
| 61 |
} |
| 62 |
|
| 63 |
/** |
| 64 |
* Sets node's value |
| 65 |
* |
| 66 |
* @param mixed $value Value |
| 67 |
* |
| 68 |
* @return $this |
| 69 |
*/ |
| 70 |
abstract public function setValue($value); |
| 71 |
|
| 72 |
/** |
| 73 |
* Return node's raw value |
| 74 |
* |
| 75 |
* @return string |
| 76 |
*/ |
| 77 |
public function getRaw() |
| 78 |
{ |
| 79 |
return $this->raw; |
| 80 |
} |
| 81 |
|
| 82 |
/** |
| 83 |
* Sets node's raw value |
| 84 |
* |
| 85 |
* @param mixed $raw Raw value |
| 86 |
* |
| 87 |
* @return $this |
| 88 |
*/ |
| 89 |
public function setRaw($raw) |
| 90 |
{ |
| 91 |
return $this->setValue($raw); |
| 92 |
} |
| 93 |
} |