ModuleConflictException   A
last analyzed

Complexity

Total Complexity 1

Size/Duplication

Total Lines 20
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Test Coverage

Coverage 0%

Importance

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

1 Method

Rating   Name   Duplication   Size   Complexity  
A forPathConflict() 0 17 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\Conflict;
13
14
use Exception;
15
use RuntimeException;
16
17
/**
18
 * Thrown when two modules have conflicting path mappings.
19
 *
20
 * @since  1.0
21
 *
22
 * @author Bernhard Schussek <[email protected]>
23
 */
24
class ModuleConflictException extends RuntimeException
25
{
26
    public static function forPathConflict(ModuleConflict $conflict, Exception $cause = null)
27
    {
28
        $moduleNames = $conflict->getModuleNames();
29
        $lastModuleName = array_pop($moduleNames);
30
31
        return new static(sprintf(
32
            'The modules "%s" and "%s" add resources for the same path '.
33
            "\"%s\", but have no override order defined between them.\n\n".
34
            "Resolutions:\n\n(1) Add the key \"override\" to the puli.json ".
35
            "of one module and set its value to the other module name.\n(2) ".
36
            'Add the key "override-order" to the puli.json of the root '.
37
            'module and define the order of the modules there.',
38
            implode('", "', $moduleNames),
39
            $lastModuleName,
40
            $conflict->getConflictingToken()
41
        ), 0, $cause);
42
    }
43
}
44