Completed
Push — master ( eeabde...efa6a6 )
by Beniamin
02:56
created

AliasManager   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 41
Duplicated Lines 0 %

Coupling/Cohesion

Components 3
Dependencies 0

Test Coverage

Coverage 33.33%

Importance

Changes 1
Bugs 0 Features 1
Metric Value
wmc 3
c 1
b 0
f 1
lcom 3
cbo 0
dl 0
loc 41
ccs 2
cts 6
cp 0.3333
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A generateNextTableAlias() 0 4 1
A generateNextColumnAlias() 0 4 1
A generateNextParameterAlias() 0 4 1
1
<?php
2
3
/**
4
 * This file is part of Phuria SQL Builder package.
5
 *
6
 * Copyright (c) 2016 Beniamin Jonatan Šimko
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
namespace Phuria\QueryBuilder\AliasManager;
13
14
/**
15
 * @author Beniamin Jonatan Šimko <[email protected]>
16
 */
17
class AliasManager
18
{
19
    /**
20
     * @var int $tableCounter
21
     */
22
    private $tableCounter = 0;
23
24
    /**
25
     * @var int $columnCounter
26
     */
27
    private $columnCounter = 0;
28
29
    /**
30
     * @var int $parameterCounter
31
     */
32
    private $parameterCounter = 0;
33
34
    /**
35
     * @return string
36
     */
37 1
    public function generateNextTableAlias()
38
    {
39 1
        return sprintf('_t%d', $this->columnCounter++);
40
    }
41
42
    /**
43
     * @return string
44
     */
45
    public function generateNextColumnAlias()
46
    {
47
        return sprintf('_v%d', $this->tableCounter++);
48
    }
49
50
    /**
51
     * @return string
52
     */
53
    public function generateNextParameterAlias()
54
    {
55
        return sprintf('?%d', $this->parameterCounter++);
56
    }
57
}