1: <?php
2: namespace Pharborist\Operators;
3:
4: use Pharborist\ExpressionNode;
5: use Pharborist\Token;
6:
7: /**
8: * A boolean '!' operation.
9: */
10: class BooleanNotNode extends UnaryOperationNode {
11:
12: /**
13: * Creates a negated version of any expression. For instance, passing a
14: * VariableNode will result in !$var.
15: *
16: * @param \Pharborist\ExpressionNode $expr
17: * The expression to negate.
18: *
19: * @return static
20: */
21: public static function fromExpression(ExpressionNode $expr) {
22: $not = new static();
23: $not->addChild(Token::not(), 'operator');
24: /** @var \Pharborist\Node $expr */
25: $not->addChild($expr->remove(), 'operand');
26: return $not;
27: }
28:
29: }
30: