packages/sql-semantics-sqlite/resources/models/Value/ExprWithExprInOpNmDbnmParenExprlist_be04cc02.php

1<?php
2
3declare(strict_types=1);
4
5namespace SqlSemantics\Statement\Model\Sqlite\Value;
6
7/**
8 * The expr SQL value; generated by bin/build-models.php.
9 *
10 * @visibility public
11 * @example Accept a structured SQL value
12 *     $write = static fn (\SqlSemantics\Statement\Model\Sqlite\Value\ExprWithExprInOpNmDbnmParenExprlist_be04cc02 $value): string => \SqlSemantics\Statement\Writer::render($value);
13 *     $write instanceof \Closure // => true
14 */
15final class ExprWithExprInOpNmDbnmParenExprlist_be04cc02 implements \SqlSemantics\Statement\Model\Sqlite\Role\CaseOperandForm, \SqlSemantics\Statement\Model\Sqlite\Role\ExprForm, \SqlSemantics\Statement\Model\Sqlite\Role\ExprlistForm, \SqlSemantics\Statement\Model\Sqlite\Role\NexprlistForm
16{
17    use \SqlSemantics\Statement\Assertion;
18
19    /**
20     * Supplies the SQL values of this form; comments are kept by the position of the symbol each precedes.
21     */
22    public function __construct(
23        public readonly \SqlSemantics\Statement\Model\Sqlite\Role\ExprForm $expr,
24        public readonly \SqlSemantics\Statement\Model\Sqlite\Role\InOpForm $inOp,
25        public readonly \SqlSemantics\Statement\Model\Sqlite\Role\NmForm $nm,
26        public readonly \SqlSemantics\Statement\Model\Sqlite\Role\DbnmForm $dbnm,
27        public readonly \SqlSemantics\Statement\Model\Sqlite\Role\ParenExprlistForm $parenExprlist,
28        public readonly \SqlSemantics\Statement\Comments $comments = new \SqlSemantics\Statement\Comments(),
29    ) {
30        $this->assert(\SqlSemantics\Statement\Model\Sqlite\Contract\Contracts::contains($expr), 'The expr must be a generated immutable SQL value.');
31        $this->assertOperandBindingStrength($expr, \SqlSemantics\Statement\Model\Sqlite\Contract\Contracts::BINDING_POWERS, array (  'sqlite-3.47.2' => 4,));
32        $this->assert(\SqlSemantics\Statement\Model\Sqlite\Contract\Contracts::contains($inOp), 'The inOp must be a generated immutable SQL value.');
33        $this->assert(\SqlSemantics\Statement\Model\Sqlite\Contract\Contracts::contains($nm), 'The nm must be a generated immutable SQL value.');
34        $this->assert(\SqlSemantics\Statement\Model\Sqlite\Contract\Contracts::contains($dbnm), 'The dbnm must be a generated immutable SQL value.');
35        $this->assert(\SqlSemantics\Statement\Model\Sqlite\Contract\Contracts::contains($parenExprlist), 'The parenExprlist must be a generated immutable SQL value.');
36    }
37
38    /**
39     * Writes SQL entirely from this value's fields.
40     */
41    public function write(\SqlSemantics\Statement\Writer $writer): void
42    {
43        $writer->comments($this->comments, 0);
44        $this->expr->write($writer);
45        $writer->comments($this->comments, 1);
46        $this->inOp->write($writer);
47        $writer->comments($this->comments, 2);
48        $this->nm->write($writer);
49        $writer->comments($this->comments, 3);
50        $this->dbnm->write($writer);
51        $writer->comments($this->comments, 4);
52        $this->parenExprlist->write($writer);
53    }
54
55    /**
56     * Returns a copy with a new expr, preserving every other field.
57     */
58    public function withExpr(\SqlSemantics\Statement\Model\Sqlite\Role\ExprForm $expr): self
59    {
60        return new self($expr, $this->inOp, $this->nm, $this->dbnm, $this->parenExprlist, $this->comments);
61    }
62
63    /**
64     * Returns a copy with a new inOp, preserving every other field.
65     */
66    public function withInOp(\SqlSemantics\Statement\Model\Sqlite\Role\InOpForm $inOp): self
67    {
68        return new self($this->expr, $inOp, $this->nm, $this->dbnm, $this->parenExprlist, $this->comments);
69    }
70
71    /**
72     * Returns a copy with a new nm, preserving every other field.
73     */
74    public function withNm(\SqlSemantics\Statement\Model\Sqlite\Role\NmForm $nm): self
75    {
76        return new self($this->expr, $this->inOp, $nm, $this->dbnm, $this->parenExprlist, $this->comments);
77    }
78
79    /**
80     * Returns a copy with a new dbnm, preserving every other field.
81     */
82    public function withDbnm(\SqlSemantics\Statement\Model\Sqlite\Role\DbnmForm $dbnm): self
83    {
84        return new self($this->expr, $this->inOp, $this->nm, $dbnm, $this->parenExprlist, $this->comments);
85    }
86
87    /**
88     * Returns a copy with a new parenExprlist, preserving every other field.
89     */
90    public function withParenExprlist(\SqlSemantics\Statement\Model\Sqlite\Role\ParenExprlistForm $parenExprlist): self
91    {
92        return new self($this->expr, $this->inOp, $this->nm, $this->dbnm, $parenExprlist, $this->comments);
93    }
94
95    /**
96     * Returns a copy with a new comments, preserving every other field.
97     */
98    public function withComments(\SqlSemantics\Statement\Comments $comments): self
99    {
100        return new self($this->expr, $this->inOp, $this->nm, $this->dbnm, $this->parenExprlist, $comments);
101    }
102}
103