Code Duplication    Length = 37-44 lines in 2 locations

src/Api/Discovery/NoSuchBindingException.php 1 location

@@ 25-61 (lines=37) @@
22
 *
23
 * @author Bernhard Schussek <[email protected]>
24
 */
25
class NoSuchBindingException extends RuntimeException
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
    public static function forUuid(Uuid $uuid, Exception $cause = null)
36
    {
37
        return new static(sprintf(
38
            'The binding with UUID "%s" does not exist.',
39
            $uuid->toString()
40
        ), 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

src/Api/NonRootModuleExpectedException.php 1 location

@@ 26-69 (lines=44) @@
23
 *
24
 * @author Bernhard Schussek <[email protected]>
25
 */
26
class NonRootModuleExpectedException extends RuntimeException
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
    public static function cannotEnableBinding(Uuid $uuid, $moduleName, Exception $cause = null)
40
    {
41
        return new static(sprintf(
42
            'Cannot enable binding "%s" in module "%s": Can only enable '.
43
            'bindings in non-root modules.',
44
            $uuid->toString(),
45
            $moduleName
46
        ), 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
    public static function cannotDisableBinding(Uuid $uuid, $moduleName, Exception $cause = null)
61
    {
62
        return new static(sprintf(
63
            'Cannot disable binding "%s" in module "%s": Can only disable '.
64
            'bindings in non-root modules.',
65
            $uuid->toString(),
66
            $moduleName
67
        ), 0, $cause);
68
    }
69
}
70