Initial commit
This commit is contained in:
commit
efa5624dab
687 changed files with 162710 additions and 0 deletions
36
kirby/src/Query/AST/TernaryNode.php
Normal file
36
kirby/src/Query/AST/TernaryNode.php
Normal file
|
|
@ -0,0 +1,36 @@
|
|||
<?php
|
||||
|
||||
namespace Kirby\Query\AST;
|
||||
|
||||
use Kirby\Query\Visitors\Visitor;
|
||||
|
||||
/**
|
||||
* Represents a ternary condition in the AST,
|
||||
* with a value for when the condition is true
|
||||
* and another value for when the condition is false
|
||||
*
|
||||
* @package Kirby Query
|
||||
* @author Roman Steiner <roman@toastlab.ch>
|
||||
* @link https://getkirby.com
|
||||
* @license https://opensource.org/licenses/MIT
|
||||
* @since 5.1.0
|
||||
* @unstable
|
||||
*/
|
||||
class TernaryNode extends Node
|
||||
{
|
||||
public function __construct(
|
||||
public Node $condition,
|
||||
public Node $false,
|
||||
public Node|null $true = null
|
||||
) {
|
||||
}
|
||||
|
||||
public function resolve(Visitor $visitor): mixed
|
||||
{
|
||||
return $visitor->ternary(
|
||||
condition: $this->condition->resolve($visitor),
|
||||
true: $this->true?->resolve($visitor),
|
||||
false: $this->false->resolve($visitor)
|
||||
);
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue