| 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\JSX; |
| 11 |
|
| 12 |
use Peast\Syntax\Node\Node; |
| 13 |
use Peast\Syntax\Node\Expression; |
| 14 |
|
| 15 |
/** |
| 16 |
* A node that represents a JSX member expression. |
| 17 |
* |
| 18 |
* @author Marco Marchiò <[email protected]> |
| 19 |
*/ |
| 20 |
class JSXMemberExpression extends Node implements Expression |
| 21 |
{ |
| 22 |
/** |
| 23 |
* Map of node properties |
| 24 |
* |
| 25 |
* @var array |
| 26 |
*/ |
| 27 |
protected $propertiesMap = array( |
| 28 |
"object" => true, |
| 29 |
"property" => true |
| 30 |
); |
| 31 |
|
| 32 |
/** |
| 33 |
* Expression's object |
| 34 |
* |
| 35 |
* @var JSXMemberExpression|JSXIdentifier |
| 36 |
*/ |
| 37 |
protected $object; |
| 38 |
|
| 39 |
/** |
| 40 |
* Expression's property |
| 41 |
* |
| 42 |
* @var JSXIdentifier |
| 43 |
*/ |
| 44 |
protected $property; |
| 45 |
|
| 46 |
/** |
| 47 |
* Returns the expression's object |
| 48 |
* |
| 49 |
* @return JSXMemberExpression|JSXIdentifier |
| 50 |
*/ |
| 51 |
public function getObject() |
| 52 |
{ |
| 53 |
return $this->object; |
| 54 |
} |
| 55 |
|
| 56 |
/** |
| 57 |
* Sets the expression's object |
| 58 |
* |
| 59 |
* @param JSXMemberExpression|JSXIdentifier $object Object |
| 60 |
* |
| 61 |
* @return $this |
| 62 |
*/ |
| 63 |
public function setObject($object) |
| 64 |
{ |
| 65 |
$this->assertType($object, array("JSX\\JSXMemberExpression", "JSX\\JSXIdentifier")); |
| 66 |
$this->object = $object; |
| 67 |
return $this; |
| 68 |
} |
| 69 |
|
| 70 |
/** |
| 71 |
* Returns the expression's property |
| 72 |
* |
| 73 |
* @return JSXIdentifier |
| 74 |
*/ |
| 75 |
public function getProperty() |
| 76 |
{ |
| 77 |
return $this->property; |
| 78 |
} |
| 79 |
|
| 80 |
/** |
| 81 |
* Sets the expression's property |
| 82 |
* |
| 83 |
* @param JSXIdentifier $property Property |
| 84 |
* |
| 85 |
* @return $this |
| 86 |
*/ |
| 87 |
public function setProperty(JSXIdentifier $property) |
| 88 |
{ |
| 89 |
$this->property = $property; |
| 90 |
return $this; |
| 91 |
} |
| 92 |
} |