Failed Conditions
Pull Request — master (#51)
by Bernhard
15:48 queued 17s
created

NameConflictException   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 18
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Test Coverage

Coverage 0%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 1
c 1
b 0
f 0
lcom 0
cbo 0
dl 0
loc 18
ccs 0
cts 4
cp 0
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A forName() 0 7 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\Module;
13
14
use Exception;
15
use RuntimeException;
16
17
/**
18
 * Thrown when two modules have the same name.
19
 *
20
 * @since  1.0
21
 *
22
 * @author Bernhard Schussek <[email protected]>
23
 */
24
class NameConflictException extends RuntimeException
25
{
26
    /**
27
     * Creates a new exception.
28
     *
29
     * @param string         $name  The conflicting name.
30
     * @param Exception|null $cause The exception that caused this exception.
31
     *
32
     * @return static The created exception.
33
     */
34
    public static function forName($name, Exception $cause = null)
35
    {
36
        return new static(sprintf(
37
            'A module with the name "%s" exists already.',
38
            $name
39
        ), 0, $cause);
40
    }
41
}
42