Failed Conditions
Pull Request — develop (#3348)
by Sergei
125:02 queued 59:58
created

Identifier::getName()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
eloc 3
dl 0
loc 6
ccs 0
cts 0
cp 0
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
crap 2
1
<?php
2
3
namespace Doctrine\DBAL\Schema;
4
5
use function assert;
6
use function is_string;
7
8
/**
9
 * An abstraction class for an asset identifier.
10
 *
11
 * Wraps identifier names like column names in indexes / foreign keys
12
 * in an abstract class for proper quotation capabilities.
13
 */
14
class Identifier extends AbstractAsset
15
{
16
    /**
17 20951
     * @param string $identifier Identifier name to wrap.
18
     * @param bool   $quote      Whether to force quoting the given identifier.
19 20951
     */
20
    public function __construct(string $identifier, bool $quote = false)
21 20951
    {
22 20951
        $this->_setName($identifier);
23
24
        if (! $quote || $this->_quoted) {
25 10757
            return;
26 10757
        }
27
28
        $this->_setName('"' . $this->getName() . '"');
29
    }
30
31
    public function getName() : string
32
    {
33
        $name = parent::getName();
34
        assert(is_string($name));
35
36
        return $name;
37
    }
38
}
39