| Conditions | 19 |
| Paths | 194 |
| Total Lines | 89 |
| Code Lines | 47 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
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 |
||
| 34 | return $instance; |
||
| 35 | } |
||
| 36 | |||
| 37 | /** |
||
| 38 | * Retreive an editor according to the module's option "form_options" |
||
| 39 | * |
||
| 40 | * @param string $caption Caption to give to the editor |
||
| 41 | * @param string $name Editor's name |
||
| 42 | * @param string $value Editor's value |
||
| 43 | * @param string $width Editor's width |
||
| 44 | * @param string $height Editor's height |
||
| 45 | * @param string $supplemental |
||
| 46 | * |
||
| 47 | * @return \XoopsFormDhtmlTextArea|\XoopsFormEditor The editor to use |
||
| 48 | */ |
||
| 49 | public static function getWysiwygForm( |
||
| 50 | $caption, |
||
| 51 | $name, |
||
| 52 | $value = '', |
||
| 53 | $width = '100%', |
||
| 54 | $height = '400px', |
||
| 55 | $supplemental = '' |
||
| 56 | ) { |
||
| 57 | $helper = Helper::getInstance(); |
||
| 58 | if (\class_exists('XoopsFormEditor')) { |
||
| 59 | $options['name'] = $name; |
||
| 60 | $options['value'] = $value; |
||
| 61 | $options['rows'] = 35; |
||
| 62 | $options['cols'] = '100%'; |
||
| 63 | $options['width'] = '100%'; |
||
| 64 | $options['height'] = '400px'; |
||
| 65 | $editor = new \XoopsFormEditor($caption, $helper->getConfig('form_options'), $options, $nohtml = false, $onfailure = 'textarea'); |
||
| 66 | } else { |
||
| 67 | $editor = new \XoopsFormDhtmlTextArea($caption, $name, $value, '100%', '100%'); |
||
| 68 | } |
||
| 69 | return $editor; |
||
| 70 | } |
||
| 71 | |||
| 72 | /** |
||
| 73 | * Create (in a link) a javascript confirmation's box |
||
| 74 | * |
||
| 75 | * @param string $message Message to display |
||
| 76 | * @param bool $form Is this a confirmation for a form ? |
||
| 77 | * |
||
| 78 | * @return string the javascript code to insert in the link (or in the form) |
||
| 79 | */ |
||
| 80 | public static function javascriptLinkConfirm($message, $form = false) |
||
| 81 | { |
||
| 82 | if (!$form) { |
||
| 83 | return "onclick=\"javascript:return confirm('" . \str_replace("'", ' ', $message) . "')\""; |
||
| 84 | } |
||
| 85 | return "onSubmit=\"javascript:return confirm('" . \str_replace("'", ' ', $message) . "')\""; |
||
| 86 | } |
||
| 87 | |||
| 88 | /** |
||
| 89 | * Redirect user with a message |
||
| 90 | * |
||
| 91 | * @param string $message message to display |
||
| 92 | * @param string $url The place where to go |
||
| 93 | * @param mixed $time |
||
| 94 | */ |
||
| 95 | public static function redirect($message = '', $url = 'index.php', $time = 2) |
||
| 96 | { |
||
| 97 | \redirect_header($url, $time, $message); |
||
| 98 | } |
||
| 99 | |||
| 100 | /** |
||
| 101 | * Internal function used to get the handler of the current module |
||
| 102 | * @return \XoopsModule The module |
||
| 103 | * @deprecated use $helper->getModule(); |
||
| 104 | */ |
||
| 105 | protected static function getModule() |
||
| 106 | { |
||
| 107 | $moduleDirName = \basename(\dirname(__DIR__)); |
||
| 108 | static $mymodule; |
||
| 109 | if (null === $mymodule) { |
||
| 110 | global $xoopsModule; |
||
| 111 | if (null !== $xoopsModule && \is_object($xoopsModule) && $moduleDirName == $xoopsModule->getVar('dirname')) { |
||
| 112 | $mymodule = $xoopsModule; |
||
| 113 | } else { |
||
| 114 | $moduleHandler = \xoops_getHandler('module'); |
||
| 115 | $mymodule = $moduleHandler->getByDirname($moduleDirName); |
||
| 116 | } |
||
| 117 | } |
||
| 118 | return $mymodule; |
||
| 119 | } |
||
| 120 | |||
| 121 | /** |
||
| 122 | * This function indicates if the current Xoops version needs to add asterisks to required fields in forms |
||
| 123 | * |
||
| 243 |
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths