Completed
Branch FET/11183/improvements-to-pue-... (232f50)
by
unknown
43:46 queued 26:36
created

InvalidRequestStackMiddlewareException   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 33
Duplicated Lines 100 %

Coupling/Cohesion

Components 0
Dependencies 1

Importance

Changes 2
Bugs 0 Features 0
Metric Value
dl 33
loc 33
rs 10
c 2
b 0
f 0
wmc 3
lcom 0
cbo 1

1 Method

Rating   Name   Duplication   Size   Complexity  
A __construct() 23 23 3

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
namespace EventEspresso\core\services\request;
4
5
use EventEspresso\core\exceptions\InvalidDataTypeException;
6
use Exception;
7
8
defined('EVENT_ESPRESSO_VERSION') || exit;
9
10
11
12
/**
13
 * Class InvalidRequestStackMiddlewareException
14
 *
15
 * @package EventEspresso\core\services\request
16
 * @author  Brent Christensen
17
 * @since   $VID:$
18
 */
19 View Code Duplication
class InvalidRequestStackMiddlewareException extends InvalidDataTypeException
20
{
21
22
    /**
23
     * @param  mixed     $middleware_app_class
24
     * @param  string    $message
25
     * @param int        $code
26
     * @param Exception $previous
27
     */
28
    public function __construct($middleware_app_class, $message = '', $code = 0, Exception $previous = null)
29
    {
30
        if(is_array($middleware_app_class)) {
31
            $middleware_app_class = reset($middleware_app_class);
32
        }
33
        if (empty($message)) {
34
            $message = sprintf(
35
                esc_html__(
36
                    'The supplied Request Stack Middleware class "%1$s" is invalid or could no be found.',
37
                    'event_espresso'
38
                ),
39
                $middleware_app_class
40
            );
41
        }
42
        parent::__construct(
43
            '$middleware_app_class',
44
            $middleware_app_class,
45
            'EventEspresso\core\services\request\middleware\Middleware',
46
            $message,
47
            $code,
48
            $previous
49
        );
50
    }
51
}
52