Debian Codegraph @

vendor/mck89/peast/lib/Peast/Syntax/Node/UnaryExpression.php

raw
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 unary expression.
14 * For example: !a
15 *
16 * @author Marco Marchiò <[email protected]>
17 */
18 class UnaryExpression extends Node implements Expression
19 {
20 /**
21 * Map of node properties
22 *
23 * @var array
24 */
25 protected $propertiesMap = array(
26 "argument" => true,
27 "operator" => false,
28 "prefix" => false
29 );
30
31 /**
32 * Expression's operator
33 *
34 * @var string
35 */
36 protected $operator;
37
38 /**
39 * Prefix flag that is always true since the operator precedes the argument
40 *
41 * @var bool
42 */
43 protected $prefix = true;
44
45 /**
46 * Expression's argument
47 *
48 * @var Expression
49 */
50 protected $argument;
51
52 /**
53 * Returns the expression's operator
54 *
55 * @return string
56 */
57 public function getOperator()
58 {
59 return $this->operator;
60 }
61
62 /**
63 * Sets the expression's operator
64 *
65 * @param string $operator Operator
66 *
67 * @return $this
68 */
69 public function setOperator($operator)
70 {
71 $this->operator = $operator;
72 return $this;
73 }
74
75 /**
76 * Returns the prefix flag that is always true since the operator precedes
77 * the argument
78 *
79 * @return bool
80 */
81 public function getPrefix()
82 {
83 return $this->prefix;
84 }
85
86 /**
87 * This method does nothing since the prefix flag is always true for
88 * unary expressions
89 *
90 * @param bool $prefix Prefix flag
91 *
92 * @return $this
93 *
94 * @codeCoverageIgnore
95 */
96 public function setPrefix($prefix)
97 {
98 return $this;
99 }
100
101 /**
102 * Returns the expression's argument
103 *
104 * @return Expression
105 */
106 public function getArgument()
107 {
108 return $this->argument;
109 }
110
111 /**
112 * Sets the expression's argument
113 *
114 * @param Expression $argument Argument
115 *
116 * @return $this
117 */
118 public function setArgument(Expression $argument)
119 {
120 $this->argument = $argument;
121 return $this;
122 }
123 }