Passed
Pull Request — master (#358)
by Arman
03:02
created

DatabaseException::operatorNotSupported()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 1
c 1
b 0
f 0
nc 1
nop 1
dl 0
loc 3
rs 10
1
<?php
2
3
/**
4
 * Quantum PHP Framework
5
 *
6
 * An open source software development framework for PHP
7
 *
8
 * @package Quantum
9
 * @author Arman Ag. <[email protected]>
10
 * @copyright Copyright (c) 2018 Softberg LLC (https://softberg.org)
11
 * @link http://quantum.softberg.org/
12
 * @since 2.9.9
13
 */
14
15
namespace Quantum\Libraries\Database\Exceptions;
16
17
use Quantum\Libraries\Database\Enums\ExceptionMessages;
18
use Quantum\App\Exceptions\BaseException;
19
20
/**
21
 * Class DatabaseException
22
 * @package Quantum\Libraries\Database
23
 */
24
class DatabaseException extends BaseException
25
{
26
27
    /**
28
     * @return DatabaseException
29
     */
30
    public static function incorrectConfig(): DatabaseException
31
    {
32
        return new static(ExceptionMessages::INCORRECT_CONFIG, E_ERROR);
33
    }
34
35
    /**
36
     * @param string $operator
37
     * @return DatabaseException
38
     */
39
    public static function operatorNotSupported(string $operator): DatabaseException
40
    {
41
        return new static(_message(ExceptionMessages::NOT_SUPPORTED_OPERATOR, [$operator]), E_WARNING);
42
    }
43
44
    /**
45
     * @param string $name
46
     * @return DatabaseException
47
     */
48
    public static function tableAlreadyExists(string $name): DatabaseException
49
    {
50
        return new static(_message(ExceptionMessages::TABLE_ALREADY_EXISTS, $name), E_ERROR);
51
    }
52
53
    /**
54
     * @param string $name
55
     * @return DatabaseException
56
     */
57
    public static function tableDoesNotExists(string $name): DatabaseException
58
    {
59
        return new static(_message(ExceptionMessages::TABLE_NOT_EXISTS, $name), E_ERROR);
60
    }
61
}