packages/sql-semantics-mysql/resources/models/Value/ShowParamWithOptFullColumnsFromOrInTableIdentOptDbWildAndWhere_f45e288e.php
1<?php
2
3declare(strict_types=1);
4
5namespace SqlSemantics\Statement\Model\MySql\Value;
6
7/**
8 * The show_param 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\ShowParamWithOptFullColumnsFromOrInTableIdentOptDbWildAndWhere_f45e288e $value): string => \SqlSemantics\Statement\Writer::render($value);
13 * $write instanceof \Closure // => true
14 */
15final class ShowParamWithOptFullColumnsFromOrInTableIdentOptDbWildAndWhere_f45e288e implements \SqlSemantics\Statement\Model\MySql\Role\ShowParamForm
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\OptFullForm $optFull,
24 public readonly string $columns,
25 public readonly \SqlSemantics\Statement\Model\MySql\Role\FromOrInForm $fromOrIn,
26 public readonly \SqlSemantics\Statement\Model\MySql\Role\TableIdentForm $tableIdent,
27 public readonly \SqlSemantics\Statement\Model\MySql\Role\OptDbForm $optDb,
28 public readonly \SqlSemantics\Statement\Model\MySql\Role\WildAndWhereForm $wildAndWhere,
29 public readonly \SqlSemantics\Statement\Comments $comments = new \SqlSemantics\Statement\Comments(),
30 ) {
31 $this->assert(\SqlSemantics\Statement\Model\MySql\Contract\Contracts::contains($optFull), 'The optFull must be a generated immutable SQL value.');
32 $this->assertMatchesPattern($columns, \SqlSemantics\Statement\Model\MySql\Contract\Contracts::SPELLINGS['COLUMNS'], 'The columns must be a complete COLUMNS lexical spelling.');
33 $this->assert(\SqlSemantics\Statement\Model\MySql\Contract\Contracts::contains($fromOrIn), 'The fromOrIn must be a generated immutable SQL value.');
34 $this->assert(\SqlSemantics\Statement\Model\MySql\Contract\Contracts::contains($tableIdent), 'The tableIdent must be a generated immutable SQL value.');
35 $this->assert(\SqlSemantics\Statement\Model\MySql\Contract\Contracts::contains($optDb), 'The optDb must be a generated immutable SQL value.');
36 $this->assert(\SqlSemantics\Statement\Model\MySql\Contract\Contracts::contains($wildAndWhere), 'The wildAndWhere must be a generated immutable SQL value.');
37 }
38
39 /**
40 * Writes SQL entirely from this value's fields.
41 */
42 public function write(\SqlSemantics\Statement\Writer $writer): void
43 {
44 $writer->comments($this->comments, 0);
45 $this->optFull->write($writer);
46 $writer->comments($this->comments, 1);
47 $writer->append($this->columns);
48 $writer->comments($this->comments, 2);
49 $this->fromOrIn->write($writer);
50 $writer->comments($this->comments, 3);
51 $this->tableIdent->write($writer);
52 $writer->comments($this->comments, 4);
53 $this->optDb->write($writer);
54 $writer->comments($this->comments, 5);
55 $this->wildAndWhere->write($writer);
56 }
57
58 /**
59 * Returns a copy with a new optFull, preserving every other field.
60 */
61 public function withOptFull(\SqlSemantics\Statement\Model\MySql\Role\OptFullForm $optFull): self
62 {
63 return new self($optFull, $this->columns, $this->fromOrIn, $this->tableIdent, $this->optDb, $this->wildAndWhere, $this->comments);
64 }
65
66 /**
67 * Returns a copy with a new columns, preserving every other field.
68 */
69 public function withColumns(string $columns): self
70 {
71 return new self($this->optFull, $columns, $this->fromOrIn, $this->tableIdent, $this->optDb, $this->wildAndWhere, $this->comments);
72 }
73
74 /**
75 * Returns a copy with a new fromOrIn, preserving every other field.
76 */
77 public function withFromOrIn(\SqlSemantics\Statement\Model\MySql\Role\FromOrInForm $fromOrIn): self
78 {
79 return new self($this->optFull, $this->columns, $fromOrIn, $this->tableIdent, $this->optDb, $this->wildAndWhere, $this->comments);
80 }
81
82 /**
83 * Returns a copy with a new tableIdent, preserving every other field.
84 */
85 public function withTableIdent(\SqlSemantics\Statement\Model\MySql\Role\TableIdentForm $tableIdent): self
86 {
87 return new self($this->optFull, $this->columns, $this->fromOrIn, $tableIdent, $this->optDb, $this->wildAndWhere, $this->comments);
88 }
89
90 /**
91 * Returns a copy with a new optDb, preserving every other field.
92 */
93 public function withOptDb(\SqlSemantics\Statement\Model\MySql\Role\OptDbForm $optDb): self
94 {
95 return new self($this->optFull, $this->columns, $this->fromOrIn, $this->tableIdent, $optDb, $this->wildAndWhere, $this->comments);
96 }
97
98 /**
99 * Returns a copy with a new wildAndWhere, preserving every other field.
100 */
101 public function withWildAndWhere(\SqlSemantics\Statement\Model\MySql\Role\WildAndWhereForm $wildAndWhere): self
102 {
103 return new self($this->optFull, $this->columns, $this->fromOrIn, $this->tableIdent, $this->optDb, $wildAndWhere, $this->comments);
104 }
105
106 /**
107 * Returns a copy with a new comments, preserving every other field.
108 */
109 public function withComments(\SqlSemantics\Statement\Comments $comments): self
110 {
111 return new self($this->optFull, $this->columns, $this->fromOrIn, $this->tableIdent, $this->optDb, $this->wildAndWhere, $comments);
112 }
113}
114