packages/sql-semantics-mysql/resources/models/Value/TableConstraintDefWithFulltextSymOptKeyOrIndexOptIdentKeyListWithExpressionOptFulltextIndexOption_1f6b4201.php
1<?php
2
3declare(strict_types=1);
4
5namespace SqlSemantics\Statement\Model\MySql\Value;
6
7/**
8 * The table_constraint_def 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\TableConstraintDefWithFulltextSymOptKeyOrIndexOptIdentKeyListWithExpressionOptFulltextIndexOption_1f6b4201 $value): string => \SqlSemantics\Statement\Writer::render($value);
13 * $write instanceof \Closure // => true
14 */
15final class TableConstraintDefWithFulltextSymOptKeyOrIndexOptIdentKeyListWithExpressionOptFulltextIndexOption_1f6b4201 implements \SqlSemantics\Statement\Model\MySql\Role\TableConstraintDefForm, \SqlSemantics\Statement\Model\MySql\Role\TableElementForm, \SqlSemantics\Statement\Model\MySql\Role\TableElementListForm
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\OptKeyOrIndexForm $optKeyOrIndex,
24 public readonly \SqlSemantics\Statement\Model\MySql\Role\OptIdentForm $optIdent,
25 public readonly \SqlSemantics\Statement\Model\MySql\Role\KeyListWithExpressionForm $keyListWithExpression,
26 public readonly \SqlSemantics\Statement\Model\MySql\Role\OptFulltextIndexOptionsForm $optFulltextIndexOptions,
27 public readonly \SqlSemantics\Statement\Comments $comments = new \SqlSemantics\Statement\Comments(),
28 ) {
29 $this->assert(\SqlSemantics\Statement\Model\MySql\Contract\Contracts::contains($optKeyOrIndex), 'The optKeyOrIndex must be a generated immutable SQL value.');
30 $this->assert(\SqlSemantics\Statement\Model\MySql\Contract\Contracts::contains($optIdent), 'The optIdent must be a generated immutable SQL value.');
31 $this->assert(\SqlSemantics\Statement\Model\MySql\Contract\Contracts::contains($keyListWithExpression), 'The keyListWithExpression must be a generated immutable SQL value.');
32 $this->assert(\SqlSemantics\Statement\Model\MySql\Contract\Contracts::contains($optFulltextIndexOptions), 'The optFulltextIndexOptions must be a generated immutable SQL value.');
33 }
34
35 /**
36 * Writes SQL entirely from this value's fields.
37 */
38 public function write(\SqlSemantics\Statement\Writer $writer): void
39 {
40 $writer->comments($this->comments, 0);
41 $writer->append('FULLTEXT');
42 $writer->comments($this->comments, 1);
43 $this->optKeyOrIndex->write($writer);
44 $writer->comments($this->comments, 2);
45 $this->optIdent->write($writer);
46 $writer->comments($this->comments, 3);
47 $writer->append('(');
48 $writer->comments($this->comments, 4);
49 $this->keyListWithExpression->write($writer);
50 $writer->comments($this->comments, 5);
51 $writer->append(')');
52 $writer->comments($this->comments, 6);
53 $this->optFulltextIndexOptions->write($writer);
54 }
55
56 /**
57 * Returns a copy with a new optKeyOrIndex, preserving every other field.
58 */
59 public function withOptKeyOrIndex(\SqlSemantics\Statement\Model\MySql\Role\OptKeyOrIndexForm $optKeyOrIndex): self
60 {
61 return new self($optKeyOrIndex, $this->optIdent, $this->keyListWithExpression, $this->optFulltextIndexOptions, $this->comments);
62 }
63
64 /**
65 * Returns a copy with a new optIdent, preserving every other field.
66 */
67 public function withOptIdent(\SqlSemantics\Statement\Model\MySql\Role\OptIdentForm $optIdent): self
68 {
69 return new self($this->optKeyOrIndex, $optIdent, $this->keyListWithExpression, $this->optFulltextIndexOptions, $this->comments);
70 }
71
72 /**
73 * Returns a copy with a new keyListWithExpression, preserving every other field.
74 */
75 public function withKeyListWithExpression(\SqlSemantics\Statement\Model\MySql\Role\KeyListWithExpressionForm $keyListWithExpression): self
76 {
77 return new self($this->optKeyOrIndex, $this->optIdent, $keyListWithExpression, $this->optFulltextIndexOptions, $this->comments);
78 }
79
80 /**
81 * Returns a copy with a new optFulltextIndexOptions, preserving every other field.
82 */
83 public function withOptFulltextIndexOptions(\SqlSemantics\Statement\Model\MySql\Role\OptFulltextIndexOptionsForm $optFulltextIndexOptions): self
84 {
85 return new self($this->optKeyOrIndex, $this->optIdent, $this->keyListWithExpression, $optFulltextIndexOptions, $this->comments);
86 }
87
88 /**
89 * Returns a copy with a new comments, preserving every other field.
90 */
91 public function withComments(\SqlSemantics\Statement\Comments $comments): self
92 {
93 return new self($this->optKeyOrIndex, $this->optIdent, $this->keyListWithExpression, $this->optFulltextIndexOptions, $comments);
94 }
95}
96