Passed
Pull Request — master (#68)
by Arman
05:55 queued 02:47
created

HookException   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 28
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 5
c 1
b 0
f 0
dl 0
loc 28
rs 10
wmc 2

2 Methods

Rating   Name   Duplication   Size   Complexity  
A hookDuplicateName() 0 3 1
A unregisteredHookName() 0 3 1
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.7.0
13
 */
14
15
namespace Quantum\Exceptions;
16
17
/**
18
 * Class HookException
19
 * @package Quantum\Exceptions
20
 */
21
class HookException extends \Exception
22
{
23
    /**
24
     * Duplicate hook implementer message
25
     */
26
    const DUPLICATE_HOOK_NAME = 'The Hook `{%1}` already registered';
27
28
    /**
29
     * Undeclared hook name message
30
     */
31
    const UNREGISTERED_HOOK_NAME = 'The Hook `{%1}` was not registered';
32
33
    /**
34
     * @param string $name
35
     * @return \Quantum\Exceptions\HookException
36
     */
37
    public static function hookDuplicateName(string $name): HookException
38
    {
39
        return new static(_message(self::DUPLICATE_HOOK_NAME, $name), E_ERROR);
40
    }
41
42
    /**
43
     * @param string $name
44
     * @return \Quantum\Exceptions\HookException
45
     */
46
    public static function unregisteredHookName(string $name): HookException
47
    {
48
        return new static(_message(self::UNREGISTERED_HOOK_NAME, $name), E_WARNING);
49
    }
50
}
51