Completed
Push — master ( ca933a...e6bad2 )
by Arman
15s queued 10s
created

DiException::circularDependency()   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 1
dl 0
loc 3
rs 10
c 0
b 0
f 0
1
<?php
2
3
declare(strict_types=1);
4
5
/**
6
 * Quantum PHP Framework
7
 *
8
 * An open source software development framework for PHP
9
 *
10
 * @package Quantum
11
 * @author Arman Ag. <[email protected]>
12
 * @copyright Copyright (c) 2018 Softberg LLC (https://softberg.org)
13
 * @link http://quantum.softberg.org/
14
 * @since 3.0.0
15
 */
16
17
namespace Quantum\Di\Exceptions;
18
19
use Quantum\Di\Enums\ExceptionMessages;
20
use Quantum\App\Exceptions\BaseException;
21
22
/**
23
 * Class DiException
24
 * @package Quantum\Di
25
 */
26
class DiException extends BaseException
27
{
28
    /**
29
     * @param string $name
30
     * @return DiException
31
     */
32
    public static function dependencyNotRegistered(string $name): DiException
33
    {
34
        return new self(_message(ExceptionMessages::DEPENDENCY_NOT_REGISTERED, [$name]), E_ERROR);
35
    }
36
37
    /**
38
     * @param string $name
39
     * @return DiException
40
     */
41
    public static function dependencyAlreadyRegistered(string $name): DiException
42
    {
43
        return new self(_message(ExceptionMessages::DEPENDENCY_ALREADY_REGISTERED, $name), E_ERROR);
44
    }
45
46
    /**
47
     * @param string $name
48
     * @return DiException
49
     */
50
    public static function dependencyNotInstantiable(string $name): DiException
51
    {
52
        return new self(_message(ExceptionMessages::DEPENDENCY_NOT_INSTANTIABLE, $name), E_ERROR);
53
    }
54
55
    /**
56
     * @param string $name
57
     * @return DiException
58
     */
59
    public static function invalidAbstractDependency(string $name): DiException
60
    {
61
        return new self(_message(ExceptionMessages::INVALID_ABSTRACT_DEPENDENCY, $name), E_ERROR);
62
    }
63
64
    /**
65
     * @param string $chain
66
     * @return DiException
67
     */
68
    public static function circularDependency(string $chain): DiException
69
    {
70
        return new self(_message(ExceptionMessages::CIRCULAR_DEPENDENCY, [$chain]), 0);
71
    }
72
73
    /**
74
     * @param string|null $entry
75
     * @return DiException
76
     */
77
    public static function invalidCallable(?string $entry = null): DiException
78
    {
79
        return new self(_message(ExceptionMessages::INVALID_CALLABLE, [$entry]), E_ERROR);
80
    }
81
}
82