RegisterException   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 50
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 4
eloc 9
dl 0
loc 50
ccs 10
cts 10
cp 1
rs 10
c 0
b 0
f 0

4 Methods

Rating   Name   Duplication   Size   Complexity  
A blank() 0 3 1
A missing() 0 5 1
A noAlias() 0 3 1
A duplicate() 0 5 1
1
<?php
2
3
namespace Maiorano\Shortcodes\Exceptions;
4
5
use Maiorano\Shortcodes\Contracts\AliasInterface;
6
7
/**
8
 * Class RegisterException.
9
 */
10
final class RegisterException extends ShortcodeException
11
{
12
    /**
13
     * @const string
14
     */
15
    const DUPLICATE = 'The shortcode \'%s\' has already been registered';
16
17
    /**
18
     * @const string
19
     */
20
    const NO_ALIAS = 'Cannot alias a shortcode that does not implement '.AliasInterface::class;
21
22
    /**
23
     * @return static
24
     */
25 2
    public static function blank(): self
26
    {
27 2
        return new static(parent::BLANK);
28
    }
29
30
    /**
31
     * @param string $name
32
     *
33
     * @return static
34
     */
35 4
    public static function missing(string $name): self
36
    {
37 4
        $e = sprintf(parent::MISSING, $name);
38
39 4
        return new static($e);
40
    }
41
42
    /**
43
     * @param string $name
44
     *
45
     * @return static
46
     */
47 1
    public static function duplicate(string $name): self
48
    {
49 1
        $e = sprintf(self::DUPLICATE, $name);
50
51 1
        return new static($e);
52
    }
53
54
    /**
55
     * @return static
56
     */
57 2
    public static function noAlias(): self
58
    {
59 2
        return new static(self::NO_ALIAS);
60
    }
61
}
62