packages/sql-semantics-sqlite/src/Model/Contract/SearchPath.php
1<?php
2
3declare(strict_types=1);
4
5namespace SqlSemantics\Platform\Sqlite\Model\Contract;
6
7use SqlSemantics\Platform\Sqlite\Model\Diagnostic\Check;
8
9/**
10 * The schemas a session searches for an unqualified relation name, in precedence order.
11 *
12 * @visibility public
13 * @example Selecting the MySQL current database
14 * (new \SqlSemantics\Platform\Sqlite\Model\Contract\SearchPath('shop'))->schemas // => ['shop']
15 */
16final class SearchPath
17{
18 /**
19 * @var non-empty-list<string> The schema names in precedence order
20 */
21 public readonly array $schemas;
22
23 /**
24 * @param string ...$schemas The schema names in precedence order; at least one, none empty
25 */
26 public function __construct(string ...$schemas)
27 {
28 $names = array_values($schemas);
29 Check::input($names !== [] && !in_array('', $names, true), 'A search path names at least one schema and no empty name.');
30 $this->schemas = $names;
31 }
32}
33