cannotEnableBinding()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 9
Code Lines 7

Duplication

Lines 9
Ratio 100 %

Code Coverage

Tests 5
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 9
loc 9
ccs 5
cts 5
cp 1
rs 9.6666
cc 1
eloc 7
nc 1
nop 3
crap 1
1
<?php
2
3
/*
4
 * This file is part of the puli/manager package.
5
 *
6
 * (c) Bernhard Schussek <[email protected]>
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
namespace Puli\Manager\Api;
13
14
use Exception;
15
use Rhumsaa\Uuid\Uuid;
16
use RuntimeException;
17
18
/**
19
 * Thrown when an operation was performed for the root module when a non-root
20
 * module was expected.
21
 *
22
 * @since  1.0
23
 *
24
 * @author Bernhard Schussek <[email protected]>
25
 */
26 View Code Duplication
class NonRootModuleExpectedException extends RuntimeException
0 ignored issues
show
Duplication introduced by
This class seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
27
{
28
    /**
29
     * Creates an exception for a binding UUID that could not be enabled in the
30
     * root module.
31
     *
32
     * @param Uuid           $uuid       The UUID.
33
     * @param string         $moduleName The name of the module.
34
     * @param Exception|null $cause      The exception that caused this
35
     *                                   exception.
36
     *
37
     * @return static The created exception.
38
     */
39 1
    public static function cannotEnableBinding(Uuid $uuid, $moduleName, Exception $cause = null)
40
    {
41 1
        return new static(sprintf(
42
            'Cannot enable binding "%s" in module "%s": Can only enable '.
43 1
            'bindings in non-root modules.',
44 1
            $uuid->toString(),
45
            $moduleName
46 1
        ), 0, $cause);
47
    }
48
49
    /**
50
     * Creates an exception for a binding UUID that could not be disabled in the
51
     * root module.
52
     *
53
     * @param Uuid           $uuid       The UUID.
54
     * @param string         $moduleName The name of the module.
55
     * @param Exception|null $cause      The exception that caused this
56
     *                                   exception.
57
     *
58
     * @return static The created exception.
59
     */
60 1
    public static function cannotDisableBinding(Uuid $uuid, $moduleName, Exception $cause = null)
61
    {
62 1
        return new static(sprintf(
63
            'Cannot disable binding "%s" in module "%s": Can only disable '.
64 1
            'bindings in non-root modules.',
65 1
            $uuid->toString(),
66
            $moduleName
67 1
        ), 0, $cause);
68
    }
69
}
70