Completed
Pull Request — staging (#840)
by
unknown
18:46
created

SubmitButton::submit_button_classes()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 9

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
nc 1
nop 0
dl 0
loc 9
rs 9.9666
c 0
b 0
f 0
1
<?php
2
3
namespace YIKES\EasyForms\Form;
4
5
trait SubmitButton {
6
7
    public function submit_button_classes() {
8
        $submit_button_classes = 'yikes-easy-mc-submit-button yikes-easy-mc-submit-button-';
9
        $submit_button_classes .= $this->form_id;
0 ignored issues
show
Bug introduced by
The property form_id does not exist. Did you maybe forget to declare it?

In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:

class MyClass { }

$x = new MyClass();
$x->foo = true;

Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion:

class MyClass {
    public $foo;
}

$x = new MyClass();
$x->foo = true;
Loading history...
10
        $submit_button_classes .= ' btn btn-primary';
11
        // Adding additional space in front of these classes.
12
        $submit_button_classes .= ' ' . $this->form_data['form_settings']['yikes-easy-mc-submit-button-classes'];
0 ignored issues
show
Bug introduced by
The property form_data does not exist. Did you maybe forget to declare it?

In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:

class MyClass { }

$x = new MyClass();
$x->foo = true;

Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion:

class MyClass {
    public $foo;
}

$x = new MyClass();
$x->foo = true;
Loading history...
13
        $submit_button_classes .= $this->admin_class;
0 ignored issues
show
Bug introduced by
The property admin_class does not exist. Did you maybe forget to declare it?

In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:

class MyClass { }

$x = new MyClass();
$x->foo = true;

Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion:

class MyClass {
    public $foo;
}

$x = new MyClass();
$x->foo = true;
Loading history...
14
        return apply_filters( 'yikes-mailchimp-form-submit-button-classes', $submit_button_classes, $this->form_id );
15
    }
16
17
    public function submit_button_text( $shortcode_prop ) {
18
        $submit_button_text = '';
0 ignored issues
show
Unused Code introduced by
$submit_button_text is not used, you could remove the assignment.

This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.

$myVar = 'Value';
$higher = false;

if (rand(1, 6) > 3) {
    $higher = true;
} else {
    $higher = false;
}

Both the $myVar assignment in line 1 and the $higher assignment in line 2 are dead. The first because $myVar is never used and the second because $higher is always overwritten for every possible time line.

Loading history...
19
        switch( true ) {
20
            case ! empty( $shortcode_prop ):
21
                $submit_button_text = $shortcode_prop;
22
            break;
23
24
            case $this->form_data['form_settings']['yikes-easy-mc-submit-button-text']:
25
                $submit_button_text = $this->form_data['form_settings']['yikes-easy-mc-submit-button-text'];
26
            break;
27
28
            default:
29
                $submit_button_text = __( 'Submit', 'yikes-inc-easy-mailchimp-extender' );
30
            break;
31
        }
32
        return apply_filters( 'yikes-mailchimp-form-submit-button-text', $submit_button_text, $this->form_id );
33
    }
34
}