Failed Conditions
Pull Request — develop (#3348)
by Sergei
10:40
created

Identifier   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 23
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 4
eloc 7
dl 0
loc 23
ccs 10
cts 10
cp 1
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 9 3
A getName() 0 6 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Doctrine\DBAL\Schema;
6
7
use function assert;
8
use function is_string;
9
10
/**
11
 * An abstraction class for an asset identifier.
12
 *
13
 * Wraps identifier names like column names in indexes / foreign keys
14
 * in an abstract class for proper quotation capabilities.
15
 */
16
class Identifier extends AbstractAsset
17
{
18
    /**
19
     * @param string $identifier Identifier name to wrap.
20
     * @param bool   $quote      Whether to force quoting the given identifier.
21
     */
22 22042
    public function __construct(string $identifier, bool $quote = false)
23
    {
24 22042
        $this->_setName($identifier);
25
26 22042
        if (! $quote || $this->_quoted) {
27 22042
            return;
28
        }
29
30 11551
        $this->_setName('"' . $this->getName() . '"');
31 11551
    }
32
33 21938
    public function getName() : string
34
    {
35 21938
        $name = parent::getName();
36 21938
        assert(is_string($name));
37
38 21938
        return $name;
39
    }
40
}
41