packages/sql-semantics-mysql/src/Statement/View/ViewCheckOption.php

1<?php
2
3declare(strict_types=1);
4
5namespace SqlSemantics\Platform\MySql\Statement\View;
6
7/**
8 * The WITH CHECK OPTION clause of an updatable view.
9 *
10 * Without CASCADED or LOCAL the check is CASCADED; the written form is kept.
11 * Each case holds the keyword written between WITH and CHECK, if any.
12 * Source: https://dev.mysql.com/doc/refman/8.4/en/view-check-option.html.
13 *
14 * @visibility public
15 * @example Reading the keyword of a case
16 *     \SqlSemantics\Platform\MySql\Statement\View\ViewCheckOption::Local->value // => 'LOCAL'
17 */
18enum ViewCheckOption: string
19{
20    case Unqualified = '';
21    case Cascaded = 'CASCADED';
22    case Local = 'LOCAL';
23
24    /**
25     * Tells whether the check also applies the conditions of the views the view is defined on.
26     */
27    public function cascades(): bool
28    {
29        return $this !== self::Local;
30    }
31}
32