RegisterException::duplicate()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 1

Importance

Changes 0
Metric Value
eloc 2
dl 0
loc 5
ccs 3
cts 3
cp 1
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 1
crap 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