| 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 a chain element. |
| 14 |
* |
| 15 |
* @author Marco Marchiò <[email protected]> |
| 16 |
*/ |
| 17 |
abstract class ChainElement extends Node implements Expression |
| 18 |
{ |
| 19 |
protected $propertiesMap = array( |
| 20 |
"optional" => false |
| 21 |
); |
| 22 |
|
| 23 |
/** |
| 24 |
* Optional flag that is true if the node is in the optional |
| 25 |
* part of a chain expression |
| 26 |
* |
| 27 |
* @var bool |
| 28 |
*/ |
| 29 |
protected $optional = false; |
| 30 |
|
| 31 |
/** |
| 32 |
* Returns the optional flag that is true if the node is in |
| 33 |
* the optional part of a chain expression |
| 34 |
* |
| 35 |
* @return bool |
| 36 |
*/ |
| 37 |
public function getOptional() |
| 38 |
{ |
| 39 |
return $this->optional; |
| 40 |
} |
| 41 |
|
| 42 |
/** |
| 43 |
* Sets the optional flag that is true if the node is in |
| 44 |
* the optional part of a chain expression |
| 45 |
* |
| 46 |
* @param bool $optional Optional flag |
| 47 |
* |
| 48 |
* @return $this |
| 49 |
*/ |
| 50 |
public function setOptional($optional) |
| 51 |
{ |
| 52 |
$this->optional = (bool) $optional; |
| 53 |
return $this; |
| 54 |
} |
| 55 |
} |