Completed
Branch GDPR/user-data-export (1838dd)
by
unknown
53:17 queued 40:13
created

AssetRegistrationException   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 23
Duplicated Lines 100 %

Coupling/Cohesion

Components 0
Dependencies 0

Importance

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

1 Method

Rating   Name   Duplication   Size   Complexity  
A __construct() 14 14 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
namespace EventEspresso\core\services\assets;
4
5
use Exception;
6
use RuntimeException;
7
8
9
/**
10
 * Class AssetRegistrationException
11
 * Thrown when a call to wp_register_script() returns false
12
 *
13
 * @package EventEspresso\core\services\assets
14
 * @author  Brent Christensen
15
 * @since   $VID:$
16
 */
17 View Code Duplication
class AssetRegistrationException extends RuntimeException
18
{
19
    /**
20
     * @param                $script_handle
21
     * @param string         $message
22
     * @param int            $code
23
     * @param Exception|null $previous
24
     */
25
    public function __construct($script_handle, $message = '', $code = 0, Exception $previous = null)
26
    {
27
        if (empty($message)) {
28
            $message = sprintf(
29
                esc_html_x(
30
                    'The "%1$s" script could not be registered with WordPress core.',
31
                    'The "script-handle" script could not be registered with WordPress core.',
32
                    'event_espresso'
33
                ),
34
                $script_handle
35
            );
36
        }
37
        parent::__construct($message, $code, $previous);
38
    }
39
}