Passed
Push — master ( 9fabf9...229147 )
by Stiofan
14:51
created

aui_bs_convert_sd_output()   B

Complexity

Conditions 2
Paths 2

Size

Total Lines 70
Code Lines 61

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 2
eloc 61
nc 2
nop 4
dl 0
loc 70
rs 8.8509
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
		$convert = array(
21
			'"ml-' => '"ms-',
22
			'"mr-' => '"me-',
23
			'"pl-' => '"ps-',
24
			'"pr-' => '"pe-',
25
			"'ml-" => "'ms-",
26
			"'mr-" => "'me-",
27
			"'pl-" => "'ps-",
28
			"'pr-" => "'pe-",
29
			' ml-' => ' ms-',
30
			' mr-' => ' me-',
31
			' pl-' => ' ps-',
32
			' pr-' => ' pe-',
33
			'.ml-' => '.ms-',
34
			'.mr-' => '.me-',
35
			'.pl-' => '.ps-',
36
			'.pr-' => '.pe-',
37
			' form-row' => ' row',
38
			' embed-responsive-item' => '',
39
			' embed-responsive' => ' ratio',
40
			'-1by1'    => '-1x1',
41
			'-4by3'    => '-4x3',
42
			'-16by9'    => '-16x9',
43
			'-21by9'    => '-21x9',
44
			'geodir-lightbox-image' => 'aui-lightbox-image',
45
			' badge-'   => ' text-bg-',
46
			'form-group'   => 'mb-3',
47
			'custom-select'   => 'form-select',
48
			'float-left'   => 'float-start',
49
			'float-right'   => 'float-end',
50
			'text-left'    => 'text-start',
51
			'text-sm-left'    => 'text-sm-start',
52
			'text-md-left'    => 'text-md-start',
53
			'text-lg-left'    => 'text-lg-start',
54
			'text-right'    => 'text-end',
55
			'text-sm-right'    => 'text-sm-end',
56
			'text-md-right'    => 'text-md-end',
57
			'text-lg-right'    => 'text-lg-end',
58
			'border-right'    => 'border-end',
59
			'border-left'    => 'border-start',
60
			'font-weight-'  => 'fw-',
61
			'btn-block'     => 'w-100',
62
			'rounded-left'  => 'rounded-start',
63
			'rounded-right'  => 'rounded-end',
64
			'font-italic' => 'fst-italic',
65
66
//			'custom-control custom-checkbox'    => 'form-check',
67
			// data
68
			' data-toggle=' => ' data-bs-toggle=',
69
			'data-ride=' => 'data-bs-ride=',
70
			'data-controlnav=' => 'data-bs-controlnav=',
71
			'data-slide='   => 'data-bs-slide=',
72
			'data-slide-to=' => 'data-bs-slide-to=',
73
			'data-target='  => 'data-bs-target=',
74
			'data-dismiss="modal"'  => 'data-bs-dismiss="modal"',
75
			'class="close"' => 'class="btn-close"',
76
			'<span aria-hidden="true">&times;</span>' => '',
77
		);
78
		$output  = str_replace(
79
			array_keys( $convert ),
80
			array_values( $convert ),
81
			$output
82
		);
83
	}
84
85
	return $output;
86
}
87
88
add_filter( 'wp_super_duper_widget_output', 'aui_bs_convert_sd_output', 10, 4 ); //$output, $instance, $args, $this
89