InvalidMiddlewareException   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 19
Duplicated Lines 42.11 %

Coupling/Cohesion

Components 0
Dependencies 0

Importance

Changes 0
Metric Value
wmc 2
lcom 0
cbo 0
dl 8
loc 19
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A forUnknownValue() 8 8 2

How to fix   Duplicated Code   

Duplicated Code

Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.

Common duplication problems, and corresponding solutions are:

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
Duplication introduced by
This method seems to be duplicated in your project.

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.

Loading history...
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