ModuleConflictException::forPathConflict()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 17
Code Lines 14

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 17
ccs 0
cts 16
cp 0
rs 9.4285
cc 1
eloc 14
nc 1
nop 2
crap 2
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