summaryrefslogtreecommitdiff
path: root/vendor/doctrine/orm/src/Query/Expr/From.php
blob: 21af0786e2764b87561e322835c4f41bc07ad310 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
<?php

declare(strict_types=1);

namespace Doctrine\ORM\Query\Expr;

use Stringable;

/**
 * Expression class for DQL from.
 *
 * @link    www.doctrine-project.org
 */
class From implements Stringable
{
    /**
     * @param class-string $from  The class name.
     * @param string       $alias The alias of the class.
     */
    public function __construct(
        protected string $from,
        protected string $alias,
        protected string|null $indexBy = null,
    ) {
    }

    /** @return class-string */
    public function getFrom(): string
    {
        return $this->from;
    }

    public function getAlias(): string
    {
        return $this->alias;
    }

    public function getIndexBy(): string|null
    {
        return $this->indexBy;
    }

    public function __toString(): string
    {
        return $this->from . ' ' . $this->alias .
                ($this->indexBy ? ' INDEX BY ' . $this->indexBy : '');
    }
}