| 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 case in a switch statement. |
| 14 |
* |
| 15 |
* @author Marco Marchiò <[email protected]> |
| 16 |
*/ |
| 17 |
class SwitchCase extends Node |
| 18 |
{ |
| 19 |
/** |
| 20 |
* Map of node properties |
| 21 |
* |
| 22 |
* @var array |
| 23 |
*/ |
| 24 |
protected $propertiesMap = array( |
| 25 |
"test" => true, |
| 26 |
"consequent" => true |
| 27 |
); |
| 28 |
|
| 29 |
/** |
| 30 |
* Test expression that is null in the "default" case |
| 31 |
* |
| 32 |
* @var Expression |
| 33 |
*/ |
| 34 |
protected $test; |
| 35 |
|
| 36 |
/** |
| 37 |
* Consequent statements array |
| 38 |
* |
| 39 |
* @var Statement[] |
| 40 |
*/ |
| 41 |
protected $consequent = array(); |
| 42 |
|
| 43 |
/** |
| 44 |
* Returns the test expression that is null in the "default" case |
| 45 |
* |
| 46 |
* @return Expression |
| 47 |
*/ |
| 48 |
public function getTest() |
| 49 |
{ |
| 50 |
return $this->test; |
| 51 |
} |
| 52 |
|
| 53 |
/** |
| 54 |
* Sets the test expression that is null in the "default" case |
| 55 |
* |
| 56 |
* @param Expression $test Test expression |
| 57 |
* |
| 58 |
* @return $this |
| 59 |
*/ |
| 60 |
public function setTest($test) |
| 61 |
{ |
| 62 |
$this->assertType($test, "Expression", true); |
| 63 |
$this->test = $test; |
| 64 |
return $this; |
| 65 |
} |
| 66 |
|
| 67 |
/** |
| 68 |
* Returns the consequent statements array |
| 69 |
* |
| 70 |
* @return Statement[] |
| 71 |
*/ |
| 72 |
public function getConsequent() |
| 73 |
{ |
| 74 |
return $this->consequent; |
| 75 |
} |
| 76 |
|
| 77 |
/** |
| 78 |
* Sets the consequent statements array |
| 79 |
* |
| 80 |
* @param Expression[] $consequent Consequent statements array |
| 81 |
* |
| 82 |
* @return $this |
| 83 |
*/ |
| 84 |
public function setConsequent($consequent) |
| 85 |
{ |
| 86 |
$this->assertArrayOf($consequent, "Statement"); |
| 87 |
$this->consequent = $consequent; |
| 88 |
return $this; |
| 89 |
} |
| 90 |
} |