cubiche /
bus
These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
| 1 | <?php |
||
| 2 | /** |
||
| 3 | * This file is part of the Cubiche/Bus package. |
||
| 4 | * |
||
| 5 | * Copyright (c) Cubiche |
||
| 6 | * |
||
| 7 | * For the full copyright and license information, please view the LICENSE |
||
| 8 | * file that was distributed with this source code. |
||
| 9 | */ |
||
| 10 | namespace Cubiche\Core\Bus\Exception; |
||
| 11 | |||
| 12 | use Cubiche\Core\Bus\MiddlewareInterface; |
||
| 13 | use InvalidArgumentException; |
||
| 14 | use Exception; |
||
| 15 | |||
| 16 | /** |
||
| 17 | * InvalidMiddlewareException class. |
||
| 18 | * |
||
| 19 | * @author Ivannis Suárez Jerez <[email protected]> |
||
| 20 | */ |
||
| 21 | class InvalidMiddlewareException extends InvalidArgumentException |
||
| 22 | { |
||
| 23 | /** |
||
| 24 | * Creates an exception for an invalid middleware. |
||
| 25 | * |
||
| 26 | * @param mixed $value |
||
| 27 | * @param Exception|null $cause |
||
| 28 | * |
||
| 29 | * @return InvalidMiddlewareException |
||
| 30 | */ |
||
| 31 | View Code Duplication | public static function forUnknownValue($value, Exception $cause = null) |
|
|
0 ignored issues
–
show
|
|||
| 32 | { |
||
| 33 | return new static(sprintf( |
||
| 34 | 'The object must be an instance of %s. Instance of %s given', |
||
| 35 | MiddlewareInterface::class, |
||
| 36 | is_object($value) ? get_class($value) : gettype($value) |
||
| 37 | ), 0, $cause); |
||
| 38 | } |
||
| 39 | } |
||
| 40 |
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.