Completed
Push — master ( d55578...b36807 )
by Arman
16s queued 12s
created

ViewException::noLayoutSet()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 0
dl 0
loc 3
rs 10
c 0
b 0
f 0
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.5.0
13
 */
14
15
namespace Quantum\Exceptions;
16
17
/**
18
 * Class ViewException
19
 * @package Quantum\Exceptions
20
 */
21
class ViewException extends \Exception
22
{
23
24
    /**
25
     * Direct view call message
26
     */
27
    const DIRECT_VIEW_INSTANCE = 'Views can not be instantiated directly, use `{%1}` class instead';
28
29
    /**
30
     * View file not found message
31
     */
32
    const LAYOUT_NOT_SET = 'Layout is not set';
33
34
    /**
35
     * View file not found message
36
     */
37
    const VIEW_FILE_NOT_FOUND = 'File `{%1}.php` does not exists';
38
39
    /**
40
     * @param string $name
41
     * @return \Quantum\Exceptions\ViewException
42
     */
43
    public static function directInstantiation(string $name): ViewException
44
    {
45
        return new static(_message(self::DIRECT_VIEW_INSTANCE, $name), E_WARNING);
46
    }
47
48
    /**
49
     * @return \Quantum\Exceptions\ViewException
50
     */
51
    public static function noLayoutSet(): ViewException
52
    {
53
        return new static(self::LAYOUT_NOT_SET, E_ERROR);
54
    }
55
56
    /**
57
     * @param string $name
58
     * @return \Quantum\Exceptions\ViewException
59
     */
60
    public static function fileNotFound(string $name): ViewException
61
    {
62
        return new static(_message(self::VIEW_FILE_NOT_FOUND, $name), E_ERROR);
63
    }
64
65
66
}
67