Completed
Push — master ( d8fbea...c06e4f )
by Arman
28s queued 12s
created

DatabaseException::ormClassNotDefined()   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 0
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.6.0
13
 */
14
15
namespace Quantum\Exceptions;
16
17
/**
18
 * Class DatabaseException
19
 * @package Quantum\Exceptions
20
 */
21
class DatabaseException extends \Exception
22
{
23
    /**
24
     * Incorrect config message
25
     */
26
    const INCORRECT_CONFIG = 'The structure of config is not correct';
27
28
    /**
29
     * Config file not found message
30
     */
31
    const CONFIG_FILE_NOT_FOUND = 'Config file `{%1}` does not exists';
32
33
    /**
34
     * ORM class not defined message
35
     */
36
    const ORM_CLASS_NOT_DEFINED = 'Missing ORM defination in config file';
37
38
    /**
39
     * Orm class not found message
40
     */
41
    const ORM_CLASS_NOT_FOUND = 'ORM `{%1}` class not found';
42
43
    /**
44
     * @return \Quantum\Exceptions\DatabaseException
45
     */
46
    public static function incorrectConfig(): DatabaseException
47
    {
48
        return new static(self::INCORRECT_CONFIG, E_ERROR);
49
    }
50
51
    /**
52
     * @return \Quantum\Exceptions\DatabaseException
53
     */
54
    public static function ormClassNotDefined(): DatabaseException
55
    {
56
        return new static(self::ORM_CLASS_NOT_DEFINED, E_ERROR);
57
    }
58
59
    /**
60
     * @param string $name
61
     * @return \Quantum\Exceptions\DatabaseException
62
     */
63
    public static function ormClassNotFound(string $name): DatabaseException
64
    {
65
        return new static(_message(self::ORM_CLASS_NOT_FOUND, $name), E_ERROR);
66
    }
67
}
68