packages/sql-semantics-mysql/resources/models/Value/TableExpressionWithOptFromClauseOptWhereClauseOptGroupClauseOptHavingClauseOptOrderClauseOptLi_3201a72e.php

1<?php
2
3declare(strict_types=1);
4
5namespace SqlSemantics\Statement\Model\MySql\Value;
6
7/**
8 * The table_expression 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\MySql\Value\TableExpressionWithOptFromClauseOptWhereClauseOptGroupClauseOptHavingClauseOptOrderClauseOptLi_3201a72e $value): string => \SqlSemantics\Statement\Writer::render($value);
13 *     $write instanceof \Closure // => true
14 */
15final class TableExpressionWithOptFromClauseOptWhereClauseOptGroupClauseOptHavingClauseOptOrderClauseOptLi_3201a72e implements \SqlSemantics\Statement\Model\MySql\Role\TableExpressionForm
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\MySql\Role\OptFromClauseForm $from,
24        public readonly \SqlSemantics\Statement\Model\MySql\Role\OptWhereClauseForm $where,
25        public readonly \SqlSemantics\Statement\Model\MySql\Role\OptGroupClauseForm $optGroupClause,
26        public readonly \SqlSemantics\Statement\Model\MySql\Role\OptHavingClauseForm $optHavingClause,
27        public readonly \SqlSemantics\Statement\Model\MySql\Role\OptOrderClauseForm $orderBy,
28        public readonly \SqlSemantics\Statement\Model\MySql\Role\OptLimitClauseForm $optLimitClause,
29        public readonly \SqlSemantics\Statement\Model\MySql\Role\OptProcedureAnalyseClauseForm $optProcedureAnalyseClause,
30        public readonly \SqlSemantics\Statement\Model\MySql\Role\OptSelectLockTypeForm $optSelectLockType,
31        public readonly \SqlSemantics\Statement\Comments $comments = new \SqlSemantics\Statement\Comments(),
32    ) {
33        $this->assert(\SqlSemantics\Statement\Model\MySql\Contract\Contracts::contains($from), 'The from must be a generated immutable SQL value.');
34        $this->assert(\SqlSemantics\Statement\Model\MySql\Contract\Contracts::contains($where), 'The where must be a generated immutable SQL value.');
35        $this->assert(\SqlSemantics\Statement\Model\MySql\Contract\Contracts::contains($optGroupClause), 'The optGroupClause must be a generated immutable SQL value.');
36        $this->assert(\SqlSemantics\Statement\Model\MySql\Contract\Contracts::contains($optHavingClause), 'The optHavingClause must be a generated immutable SQL value.');
37        $this->assert(\SqlSemantics\Statement\Model\MySql\Contract\Contracts::contains($orderBy), 'The orderBy must be a generated immutable SQL value.');
38        $this->assert(\SqlSemantics\Statement\Model\MySql\Contract\Contracts::contains($optLimitClause), 'The optLimitClause must be a generated immutable SQL value.');
39        $this->assert(\SqlSemantics\Statement\Model\MySql\Contract\Contracts::contains($optProcedureAnalyseClause), 'The optProcedureAnalyseClause must be a generated immutable SQL value.');
40        $this->assert(\SqlSemantics\Statement\Model\MySql\Contract\Contracts::contains($optSelectLockType), 'The optSelectLockType must be a generated immutable SQL value.');
41    }
42
43    /**
44     * Writes SQL entirely from this value's fields.
45     */
46    public function write(\SqlSemantics\Statement\Writer $writer): void
47    {
48        $writer->comments($this->comments, 0);
49        $this->from->write($writer);
50        $writer->comments($this->comments, 1);
51        $this->where->write($writer);
52        $writer->comments($this->comments, 2);
53        $this->optGroupClause->write($writer);
54        $writer->comments($this->comments, 3);
55        $this->optHavingClause->write($writer);
56        $writer->comments($this->comments, 4);
57        $this->orderBy->write($writer);
58        $writer->comments($this->comments, 5);
59        $this->optLimitClause->write($writer);
60        $writer->comments($this->comments, 6);
61        $this->optProcedureAnalyseClause->write($writer);
62        $writer->comments($this->comments, 7);
63        $this->optSelectLockType->write($writer);
64    }
65
66    /**
67     * Returns a copy with a new from, preserving every other field.
68     */
69    public function withFrom(\SqlSemantics\Statement\Model\MySql\Role\OptFromClauseForm $from): self
70    {
71        return new self($from, $this->where, $this->optGroupClause, $this->optHavingClause, $this->orderBy, $this->optLimitClause, $this->optProcedureAnalyseClause, $this->optSelectLockType, $this->comments);
72    }
73
74    /**
75     * Returns a copy with a new where, preserving every other field.
76     */
77    public function withWhere(\SqlSemantics\Statement\Model\MySql\Role\OptWhereClauseForm $where): self
78    {
79        return new self($this->from, $where, $this->optGroupClause, $this->optHavingClause, $this->orderBy, $this->optLimitClause, $this->optProcedureAnalyseClause, $this->optSelectLockType, $this->comments);
80    }
81
82    /**
83     * Returns a copy with a new optGroupClause, preserving every other field.
84     */
85    public function withOptGroupClause(\SqlSemantics\Statement\Model\MySql\Role\OptGroupClauseForm $optGroupClause): self
86    {
87        return new self($this->from, $this->where, $optGroupClause, $this->optHavingClause, $this->orderBy, $this->optLimitClause, $this->optProcedureAnalyseClause, $this->optSelectLockType, $this->comments);
88    }
89
90    /**
91     * Returns a copy with a new optHavingClause, preserving every other field.
92     */
93    public function withOptHavingClause(\SqlSemantics\Statement\Model\MySql\Role\OptHavingClauseForm $optHavingClause): self
94    {
95        return new self($this->from, $this->where, $this->optGroupClause, $optHavingClause, $this->orderBy, $this->optLimitClause, $this->optProcedureAnalyseClause, $this->optSelectLockType, $this->comments);
96    }
97
98    /**
99     * Returns a copy with a new orderBy, preserving every other field.
100     */
101    public function withOrderBy(\SqlSemantics\Statement\Model\MySql\Role\OptOrderClauseForm $orderBy): self
102    {
103        return new self($this->from, $this->where, $this->optGroupClause, $this->optHavingClause, $orderBy, $this->optLimitClause, $this->optProcedureAnalyseClause, $this->optSelectLockType, $this->comments);
104    }
105
106    /**
107     * Returns a copy with a new optLimitClause, preserving every other field.
108     */
109    public function withOptLimitClause(\SqlSemantics\Statement\Model\MySql\Role\OptLimitClauseForm $optLimitClause): self
110    {
111        return new self($this->from, $this->where, $this->optGroupClause, $this->optHavingClause, $this->orderBy, $optLimitClause, $this->optProcedureAnalyseClause, $this->optSelectLockType, $this->comments);
112    }
113
114    /**
115     * Returns a copy with a new optProcedureAnalyseClause, preserving every other field.
116     */
117    public function withOptProcedureAnalyseClause(\SqlSemantics\Statement\Model\MySql\Role\OptProcedureAnalyseClauseForm $optProcedureAnalyseClause): self
118    {
119        return new self($this->from, $this->where, $this->optGroupClause, $this->optHavingClause, $this->orderBy, $this->optLimitClause, $optProcedureAnalyseClause, $this->optSelectLockType, $this->comments);
120    }
121
122    /**
123     * Returns a copy with a new optSelectLockType, preserving every other field.
124     */
125    public function withOptSelectLockType(\SqlSemantics\Statement\Model\MySql\Role\OptSelectLockTypeForm $optSelectLockType): self
126    {
127        return new self($this->from, $this->where, $this->optGroupClause, $this->optHavingClause, $this->orderBy, $this->optLimitClause, $this->optProcedureAnalyseClause, $optSelectLockType, $this->comments);
128    }
129
130    /**
131     * Returns a copy with a new comments, preserving every other field.
132     */
133    public function withComments(\SqlSemantics\Statement\Comments $comments): self
134    {
135        return new self($this->from, $this->where, $this->optGroupClause, $this->optHavingClause, $this->orderBy, $this->optLimitClause, $this->optProcedureAnalyseClause, $this->optSelectLockType, $comments);
136    }
137}
138