NoSuchBindingException::forUuid()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 7
Code Lines 5

Duplication

Lines 7
Ratio 100 %

Code Coverage

Tests 5
CRAP Score 1

Importance

Changes 0
Metric Value
dl 7
loc 7
c 0
b 0
f 0
ccs 5
cts 5
cp 1
rs 9.4285
cc 1
eloc 5
nc 1
nop 2
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\Discovery;
13
14
use Exception;
15
use Rhumsaa\Uuid\Uuid;
16
use RuntimeException;
17
18
/**
19
 * Thrown when a binding was not found.
20
 *
21
 * @since  1.0
22
 *
23
 * @author Bernhard Schussek <[email protected]>
24
 */
25 View Code Duplication
class NoSuchBindingException 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...
26
{
27
    /**
28
     * Creates an exception for a UUID that was not found.
29
     *
30
     * @param Uuid           $uuid  The UUID.
31
     * @param Exception|null $cause The exception that caused this exception.
32
     *
33
     * @return static The created exception.
34
     */
35 4
    public static function forUuid(Uuid $uuid, Exception $cause = null)
36
    {
37 4
        return new static(sprintf(
38 4
            'The binding with UUID "%s" does not exist.',
39 4
            $uuid->toString()
40 4
        ), 0, $cause);
41
    }
42
43
    /**
44
     * Creates an exception for a UUID that was not found in a given module.
45
     *
46
     * @param Uuid           $uuid       The UUID.
47
     * @param string         $moduleName The name of the containing module.
48
     * @param Exception|null $cause      The exception that caused this
49
     *                                   exception.
50
     *
51
     * @return static The created exception.
52
     */
53
    public static function forUuidAndModule(Uuid $uuid, $moduleName, Exception $cause = null)
54
    {
55
        return new static(sprintf(
56
            'The binding with UUID "%s" does not exist in module "%s".',
57
            $uuid->toString(),
58
            $moduleName
59
        ), 0, $cause);
60
    }
61
}
62