Identifier.php 704 Bytes
Newer Older
1 2
<?php

Michael Moravec's avatar
Michael Moravec committed
3 4
declare(strict_types=1);

5 6 7 8 9 10 11 12 13 14 15 16
namespace Doctrine\DBAL\Schema;

/**
 * An abstraction class for an asset identifier.
 *
 * Wraps identifier names like column names in indexes / foreign keys
 * in an abstract class for proper quotation capabilities.
 */
class Identifier extends AbstractAsset
{
    /**
     * @param string $identifier Identifier name to wrap.
17
     * @param bool   $quote      Whether to force quoting the given identifier.
18
     */
19
    public function __construct(string $identifier, bool $quote = false)
20 21
    {
        $this->_setName($identifier);
22

23 24
        if (! $quote || $this->_quoted) {
            return;
25
        }
26 27

        $this->_setName('"' . $this->getName() . '"');
28
    }
29
}