Passed
Push — master ( 98a9e1...506bd5 )
by Brian
07:05
created

aui_bs_convert_sd_output()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 52
Code Lines 42

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 2
eloc 42
nc 2
nop 4
dl 0
loc 52
rs 9.248
c 1
b 0
f 0

How to fix   Long Method   

Long Method

Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.

For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.

Commonly applied refactorings include:

1
<?php
2
/**
3
 * Functionality to convert BS4 to BS5.
4
 */
5
6
/**
7
 * Convert BS4 HTML to BS5 HTML from Super Duper output.
8
 *
9
 * @param $output
10
 * @param $instance
11
 * @param $args
12
 * @param $sd
13
 *
14
 * @return array|mixed|string|string[]
15
 */
16
function aui_bs_convert_sd_output( $output, $instance = '', $args = '', $sd = '' ) {
0 ignored issues
show
Unused Code introduced by
The parameter $sd is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

16
function aui_bs_convert_sd_output( $output, $instance = '', $args = '', /** @scrutinizer ignore-unused */ $sd = '' ) {

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
Unused Code introduced by
The parameter $instance is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

16
function aui_bs_convert_sd_output( $output, /** @scrutinizer ignore-unused */ $instance = '', $args = '', $sd = '' ) {

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
Unused Code introduced by
The parameter $args is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

16
function aui_bs_convert_sd_output( $output, $instance = '', /** @scrutinizer ignore-unused */ $args = '', $sd = '' ) {

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
17
	global $aui_bs5;
18
19
	if ( $aui_bs5 ) {
20
21
		$convert = array(
22
			'ml-'                   => 'ms-',
23
			'mr-'                   => 'me-',
24
			'pl-'                   => 'ps-',
25
			'pr-'                   => 'pe-',
26
			' form-row'              => ' row',
27
			' embed-responsive-item' => '',
28
			' embed-responsive' => ' ratio',
29
			'-1by1'    => '-1x1',
30
			'-4by3'    => '-4x3',
31
			'-16by9'    => '-16x9',
32
			'-21by9'    => '-21x9',
33
			'geodir-lightbox-image' => 'aui-lightbox-image',
34
			' badge-'   => ' text-bg-',
35
			'form-group'   => 'mb-3',
36
			'custom-select'   => 'form-select',
37
			'float-left'   => 'float-start',
38
			'float-right'   => 'float-end',
39
			'text-left'    => 'text-start',
40
			'text-right'    => 'text-end',
41
			'border-right'    => 'border-end',
42
			'border-left'    => 'border-start',
43
			'font-weight-'  => 'fw-',
44
			'btn-block'     => 'w-100',
45
			'rounded-left'  => 'rounded-start',
46
			'rounded-right'  => 'rounded-left',
47
48
//			'custom-control custom-checkbox'    => 'form-check',
49
			// data
50
			' data-toggle=' => ' data-bs-toggle=',
51
			'data-ride=' => 'data-bs-ride=',
52
			'data-controlnav=' => 'data-bs-controlnav=',
53
			'data-slide='   => 'data-bs-slide=',
54
			'data-slide-to=' => 'data-bs-slide-to=',
55
			'data-target='  => 'data-bs-target=',
56
			'data-dismiss="modal"'  => 'data-bs-dismiss="modal"',
57
			'class="close"' => 'class="btn-close"',
58
			'<span aria-hidden="true">&times;</span>' => '',
59
		);
60
		$output  = str_replace(
61
			array_keys( $convert ),
62
			array_values( $convert ),
63
			$output
64
		);
65
	}
66
67
	return $output;
68
}
69
70
add_filter( 'wp_super_duper_widget_output', 'aui_bs_convert_sd_output', 10, 4 ); //$output, $instance, $args, $this
71