Failed Conditions
Pull Request — master (#2762)
by Evgenij
04:45
created

QueryException::transactionRequired()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 4
ccs 2
cts 2
cp 1
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 0
crap 1
1
<?php
2
/*
3
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
4
 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
5
 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
6
 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
7
 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
8
 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
9
 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
10
 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
11
 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
12
 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
13
 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
14
 *
15
 * This software consists of voluntary contributions made by many individuals
16
 * and is licensed under the MIT license. For more information, see
17
 * <http://www.doctrine-project.org>.
18
 */
19
declare(strict_types=1);
20
21
namespace Doctrine\DBAL\Query;
22
23
use Doctrine\DBAL\DBALException;
24
25
/**
26
 * @since 2.1.4
27
 */
28
class QueryException extends DBALException
29
{
30
    /**
31
     * Throws when query must be run in active transaction
32
     *
33
     * @return \Doctrine\DBAL\Query\QueryException
34
     */
35 1
    static public function transactionRequired(): QueryException
0 ignored issues
show
Coding Style introduced by
As per PSR2, the static declaration should come after the visibility declaration.
Loading history...
36
    {
37 1
        return new self('This query requires active transaction for completing.');
38
    }
39
40
    /**
41
     * @param string $alias
42
     * @param array  $registeredAliases
43
     *
44
     * @return \Doctrine\DBAL\Query\QueryException
45
     */
46 1
    static public function unknownAlias(string $alias, array $registeredAliases): QueryException
0 ignored issues
show
Coding Style introduced by
As per PSR2, the static declaration should come after the visibility declaration.
Loading history...
47
    {
48 1
        return new self("The given alias '" . $alias . "' is not part of " .
49
            "any FROM or JOIN clause table. The currently registered " .
50 1
            "aliases are: " . implode(", ", $registeredAliases) . ".");
51
    }
52
53
    /**
54
     * @param string $alias
55
     * @param array  $registeredAliases
56
     *
57
     * @return \Doctrine\DBAL\Query\QueryException
58
     */
59 1
    static public function nonUniqueAlias(string $alias, array $registeredAliases): QueryException
0 ignored issues
show
Coding Style introduced by
As per PSR2, the static declaration should come after the visibility declaration.
Loading history...
60
    {
61 1
        return new self("The given alias '" . $alias . "' is not unique " .
62
            "in FROM and JOIN clause table. The currently registered " .
63 1
            "aliases are: " . implode(", ", $registeredAliases) . ".");
64
    }
65
}
66