Completed
Pull Request — master (#3685)
by
unknown
62:27
created

QueryException   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 36
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 3
eloc 7
dl 0
loc 36
ccs 8
cts 8
cp 1
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A unknownAlias() 0 5 1
A nonUniqueAlias() 0 5 1
A joinNotAllowed() 0 3 1
1
<?php
2
3
namespace Doctrine\DBAL\Query;
4
5
use Doctrine\DBAL\DBALException;
6
use function implode;
7
8
class QueryException extends DBALException
9
{
10
    /**
11
     * @param string   $alias
12
     * @param string[] $registeredAliases
13
     *
14
     * @return \Doctrine\DBAL\Query\QueryException
15
     */
16 52
    public static function unknownAlias($alias, $registeredAliases)
17
    {
18 52
        return new self("The given alias '" . $alias . "' is not part of " .
19 52
            'any FROM or JOIN clause table. The currently registered ' .
20 52
            'aliases are: ' . implode(', ', $registeredAliases) . '.');
21
    }
22
23
    /**
24
     * @param string   $alias
25
     * @param string[] $registeredAliases
26
     *
27
     * @return \Doctrine\DBAL\Query\QueryException
28
     */
29 27
    public static function nonUniqueAlias($alias, $registeredAliases)
30
    {
31 27
        return new self("The given alias '" . $alias . "' is not unique " .
32 27
            'in FROM and JOIN clause table. The currently registered ' .
33 27
            'aliases are: ' . implode(', ', $registeredAliases) . '.');
34
    }
35
36
    /**
37
     * @param string $action
38
     *
39
     * @return \Doctrine\DBAL\Query\QueryException
40
     */
41
    public static function joinNotAllowed(string $action) : self
42
    {
43
        return new self('JOIN is not allowed for ' . $action);
44
    }
45
}
46