ListQueryException::getDql()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 1
c 1
b 0
f 0
dl 0
loc 3
ccs 2
cts 2
cp 1
rs 10
cc 1
nc 1
nop 0
crap 1
1
<?php
2
3
namespace Povs\ListerBundle\Exception;
4
5
use Throwable;
6
7
/**
8
 * @author Povilas Margaiatis <[email protected]>
9
 */
10
class ListQueryException extends ListException
11
{
12
    /**
13
     * @var string
14
     */
15
    private $ormError;
16
17
    /**
18
     * @var string
19
     */
20
    private $dql;
21
22
    /**
23
     * ListQueryException constructor.
24
     *
25
     * @param string         $ormError error message that is thrown by ORM
26
     * @param string         $dql      DQL that is built
27
     * @param string         $message
28
     * @param int            $code
29
     * @param Throwable|null $previous
30
     */
31 6
    public function __construct(string $ormError, string $dql, $message = '', $code = 500, Throwable $previous = null)
32
    {
33 6
        parent::__construct($message, $code, $previous);
34 6
        $this->ormError = $ormError;
35 6
        $this->dql = $dql;
36
    }
37
38
    /**
39
     * @param string $ormError
40
     * @param string $dql
41
     *
42
     * @return ListException
43
     */
44 4
    public static function invalidQueryConfiguration(string $ormError, string $dql): ListException
45
    {
46 4
        return new self(
47 4
            $ormError,
48 4
            $dql,
49 4
            sprintf('Query error: %s. DQL: %s', $ormError, $dql)
50 4
        );
51
    }
52
53
    /**
54
     * @return string
55
     */
56 1
    public function getOrmError(): string
57
    {
58 1
        return $this->ormError;
59
    }
60
61
    /**
62
     * @return string
63
     */
64 1
    public function getDql(): string
65
    {
66 1
        return $this->dql;
67
    }
68
}
69