| 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 |
* A node that represents an object literal. |
| 14 |
* For example: {a: 1, b: 2, c: 3} |
| 15 |
* |
| 16 |
* @author Marco Marchiò <[email protected]> |
| 17 |
*/ |
| 18 |
class ObjectExpression extends Node implements Expression |
| 19 |
{ |
| 20 |
/** |
| 21 |
* Map of node properties |
| 22 |
* |
| 23 |
* @var array |
| 24 |
*/ |
| 25 |
protected $propertiesMap = array( |
| 26 |
"properties" => true |
| 27 |
); |
| 28 |
|
| 29 |
/** |
| 30 |
* Object properties |
| 31 |
* |
| 32 |
* @var Property[] |
| 33 |
*/ |
| 34 |
protected $properties = array(); |
| 35 |
|
| 36 |
/** |
| 37 |
* Returns object properties |
| 38 |
* |
| 39 |
* @return Property[] |
| 40 |
*/ |
| 41 |
public function getProperties() |
| 42 |
{ |
| 43 |
return $this->properties; |
| 44 |
} |
| 45 |
|
| 46 |
/** |
| 47 |
* Sets object properties |
| 48 |
* |
| 49 |
* @param Property[] $properties Object properties |
| 50 |
* |
| 51 |
* @return $this |
| 52 |
*/ |
| 53 |
public function setProperties($properties) |
| 54 |
{ |
| 55 |
$this->assertArrayOf($properties, array("Property", "SpreadElement")); |
| 56 |
$this->properties = $properties; |
| 57 |
return $this; |
| 58 |
} |
| 59 |
} |