| Conditions | 1 |
| Paths | 1 |
| Total Lines | 95 |
| Code Lines | 70 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 1 |
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:
If many parameters/temporary variables are present:
| 1 | <?php |
||
| 50 | public function get_examples(){ |
||
| 51 | $output = ''; |
||
| 52 | |||
| 53 | |||
| 54 | // open form |
||
| 55 | $output .= "<form class='p-5 m-5 border rounded'>"; |
||
| 56 | |||
| 57 | // input example |
||
| 58 | $output .= aui()->input(array( |
||
| 59 | 'type' => 'text', |
||
| 60 | 'id' => 'text-example', |
||
| 61 | 'name' => 'text-example', |
||
| 62 | 'placeholder' => 'text placeholder', |
||
| 63 | 'title' => 'Text input example', |
||
| 64 | 'value' => '', |
||
| 65 | 'required' => false, |
||
| 66 | 'help_text' => 'help text', |
||
| 67 | 'label' => 'Text input example label' |
||
| 68 | )); |
||
| 69 | |||
| 70 | // input example |
||
| 71 | $output .= aui()->input(array( |
||
| 72 | 'type' => 'url', |
||
| 73 | 'id' => 'text-example2', |
||
| 74 | 'name' => 'text-example', |
||
| 75 | 'placeholder' => 'url placeholder', |
||
| 76 | 'title' => 'Text input example', |
||
| 77 | 'value' => '', |
||
| 78 | 'required' => false, |
||
| 79 | 'help_text' => 'help text', |
||
| 80 | 'label' => 'Text input example label' |
||
| 81 | )); |
||
| 82 | |||
| 83 | // checkbox example |
||
| 84 | $output .= aui()->input(array( |
||
| 85 | 'type' => 'checkbox', |
||
| 86 | 'id' => 'checkbox-example', |
||
| 87 | 'name' => 'checkbox-example', |
||
| 88 | 'placeholder' => 'checkbox-example', |
||
| 89 | 'title' => 'Checkbox example', |
||
| 90 | 'value' => '1', |
||
| 91 | 'checked' => true, |
||
| 92 | 'required' => false, |
||
| 93 | 'help_text' => 'help text', |
||
| 94 | 'label' => 'Checkbox checked' |
||
| 95 | )); |
||
| 96 | |||
| 97 | // checkbox example |
||
| 98 | $output .= aui()->input(array( |
||
| 99 | 'type' => 'checkbox', |
||
| 100 | 'id' => 'checkbox-example2', |
||
| 101 | 'name' => 'checkbox-example2', |
||
| 102 | 'placeholder' => 'checkbox-example', |
||
| 103 | 'title' => 'Checkbox example', |
||
| 104 | 'value' => '1', |
||
| 105 | 'checked' => false, |
||
| 106 | 'required' => false, |
||
| 107 | 'help_text' => 'help text', |
||
| 108 | 'label' => 'Checkbox un-checked' |
||
| 109 | )); |
||
| 110 | |||
| 111 | // switch example |
||
| 112 | $output .= aui()->input(array( |
||
| 113 | 'type' => 'checkbox', |
||
| 114 | 'id' => 'switch-example', |
||
| 115 | 'name' => 'switch-example', |
||
| 116 | 'placeholder' => 'checkbox-example', |
||
| 117 | 'title' => 'Switch example', |
||
| 118 | 'value' => '1', |
||
| 119 | 'checked' => true, |
||
| 120 | 'switch' => true, |
||
| 121 | 'required' => false, |
||
| 122 | 'help_text' => 'help text', |
||
| 123 | 'label' => 'Switch on' |
||
| 124 | )); |
||
| 125 | |||
| 126 | // switch example |
||
| 127 | $output .= aui()->input(array( |
||
| 128 | 'type' => 'checkbox', |
||
| 129 | 'id' => 'switch-example2', |
||
| 130 | 'name' => 'switch-example2', |
||
| 131 | 'placeholder' => 'checkbox-example', |
||
| 132 | 'title' => 'Switch example', |
||
| 133 | 'value' => '1', |
||
| 134 | 'checked' => false, |
||
| 135 | 'switch' => true, |
||
| 136 | 'required' => false, |
||
| 137 | 'help_text' => 'help text', |
||
| 138 | 'label' => 'Switch off' |
||
| 139 | )); |
||
| 140 | |||
| 141 | // close form |
||
| 142 | $output .= "</form>"; |
||
| 143 | |||
| 144 | return $output; |
||
| 145 | } |
||
| 147 | new AyeCode_UI_Plugin(); |
In general, usage of exit should be done with care and only when running in a scripting context like a CLI script.