packages/ztd-query-core/src/Platform/CopyTarget.php

1<?php
2
3declare(strict_types=1);
4
5namespace ZtdQuery\Platform;
6
7/**
8 * What a COPY statement is written against.
9 *
10 * The relation as it was named, which may be qualified, and the columns the
11 * rows carry in the order they carry them.
12 */
13final class CopyTarget
14{
15    /**
16     * @param non-empty-list<string> $relation
17     * @param non-empty-list<string> $columns
18     */
19    public function __construct(
20        public readonly array $relation,
21        public readonly array $columns,
22    ) {
23    }
24
25    /**
26     * Table name.
27     *
28     * @return string
29     */
30    public function tableName(): string
31    {
32        return $this->relation[count($this->relation) - 1];
33    }
34}
35