These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
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\Repository; |
||
13 | |||
14 | use Exception; |
||
15 | use RuntimeException; |
||
16 | |||
17 | /** |
||
18 | * Thrown when a path mapping was not found. |
||
19 | * |
||
20 | * @since 1.0 |
||
21 | * |
||
22 | * @author Bernhard Schussek <[email protected]> |
||
23 | */ |
||
24 | View Code Duplication | class NoSuchPathMappingException extends RuntimeException |
|
0 ignored issues
–
show
|
|||
25 | { |
||
26 | /** |
||
27 | * Creates an exception for a repository path. |
||
28 | * |
||
29 | * @param string $path The repository path. |
||
30 | * @param Exception|null $cause The exception that caused this exception. |
||
31 | * |
||
32 | * @return static The created exception. |
||
33 | */ |
||
34 | 1 | public static function forRepositoryPath($path, Exception $cause = null) |
|
35 | { |
||
36 | 1 | return new static(sprintf( |
|
37 | 1 | 'The repository path "%s" is not mapped.', |
|
38 | $path |
||
39 | 1 | ), 0, $cause); |
|
40 | } |
||
41 | |||
42 | /** |
||
43 | * Creates an exception for a repository path and a package name. |
||
44 | * |
||
45 | * @param string $path The repository path. |
||
46 | * @param string $packageName The name of the containing package. |
||
47 | * @param Exception|null $cause The exception that caused this |
||
48 | * exception. |
||
49 | * |
||
50 | * @return static The created exception. |
||
51 | */ |
||
52 | 4 | public static function forRepositoryPathAndPackage($path, $packageName, Exception $cause = null) |
|
53 | { |
||
54 | 4 | return new static(sprintf( |
|
55 | 4 | 'The repository path "%s" is not mapped in package "%s".', |
|
56 | $path, |
||
57 | $packageName |
||
58 | 4 | ), 0, $cause); |
|
59 | } |
||
60 | } |
||
61 |
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.