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

ServiceException::undefinedMethod()   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
/**
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 ServiceException
19
 * @package Quantum\Exceptions
20
 */
21
class ServiceException extends \Exception
22
{
23
    /**
24
     * Service not found message
25
     */
26
    const SERVICE_NOT_FOUND = 'Service `{%1}` not found';
27
28
    /**
29
     * Model not instance of QtModel
30
     */
31
    const NOT_INSTANCE_OF_SERVICE = 'Service `{%1}` is not instance of `{%2}`';
32
33
    /**
34
     * Undefined method
35
     */
36
    const UNDEFINED_METHOD = 'The method `{%1}` is not defined';
37
38
    /**
39
     * @param string $name
40
     * @return \Quantum\Exceptions\ServiceException
41
     */
42
    public static function serviceNotFound(string $name): ServiceException
43
    {
44
        return new static(_message(self::SERVICE_NOT_FOUND, $name), E_ERROR);
45
    }
46
47
    /**
48
     * @param array $names
49
     * @return \Quantum\Exceptions\ServiceException
50
     */
51
    public static function notServiceInstance(array $names): ServiceException
52
    {
53
        return new static(_message(self::NOT_INSTANCE_OF_SERVICE, $names), E_ERROR);
54
    }
55
56
    /**
57
     * @param string $name
58
     * @return \Quantum\Exceptions\ServiceException
59
     */
60
    public static function undefinedMethod(string $name): ServiceException
61
    {
62
        return new static(_message(self::UNDEFINED_METHOD, $name), E_ERROR);
63
    }
64
}
65