| Conditions | 2 |
| Paths | 1 |
| Total Lines | 74 |
| Code Lines | 67 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 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 |
||
| 74 | function phpbb_replace_bbc($message) |
||
| 75 | { |
||
| 76 | $message = preg_replace( |
||
| 77 | array( |
||
| 78 | '~\[quote="(.+?)"\:(.+?)\]~is', |
||
| 79 | '~\[quote\:(.+?)\]~is', |
||
| 80 | '~\[/quote\:(.+?)\]~is', |
||
| 81 | '~\[b\:(.+?)\]~is', |
||
| 82 | '~\[/b\:(.+?)\]~is', |
||
| 83 | '~\[i\:(.+?)\]~is', |
||
| 84 | '~\[/i\:(.+?)\]~is', |
||
| 85 | '~\[u\:(.+?)\]~is', |
||
| 86 | '~\[/u\:(.+?)\]~is', |
||
| 87 | '~\[url\:(.+?)\]~is', |
||
| 88 | '~\[/url\:(.+?)\]~is', |
||
| 89 | '~\[url=(.+?)\:(.+?)\]~is', |
||
| 90 | '~\[/url\:(.+?)\]~is', |
||
| 91 | '~\<a(.+?) href="(.+?)">(.+?)</a>~is', |
||
| 92 | '~\[img\:(.+?)\]~is', |
||
| 93 | '~\[/img\:(.+?)\]~is', |
||
| 94 | '~\[size=(.+?)\:(.+?)\]~is', |
||
| 95 | '~\[/size\:(.+?)?\]~is', |
||
| 96 | '~\[color=(.+?)\:(.+?)\]~is', |
||
| 97 | '~\[/color\:(.+?)\]~is', |
||
| 98 | '~\[code=(.+?)\:(.+?)\]~is', |
||
| 99 | '~\[code\:(.+?)\]~is', |
||
| 100 | '~\[/code\:(.+?)\]~is', |
||
| 101 | '~\[list=(.+?)\:(.+?)\]~is', |
||
| 102 | '~\[list\:(.+?)\]~is', |
||
| 103 | '~\[/list\:(.+?)\]~is', |
||
| 104 | '~\[\*\:(.+?)\]~is', |
||
| 105 | '~\[/\*\:(.+?)\]~is', |
||
| 106 | '~\<img src=\"{SMILIES_PATH}/(.+?)\" alt=\"(.+?)\" title=\"(.+?)\" /\>~is', |
||
| 107 | ), |
||
| 108 | array( |
||
| 109 | '[quote author="$1"]', |
||
| 110 | '[quote]', |
||
| 111 | '[/quote]', |
||
| 112 | '[b]', |
||
| 113 | '[/b]', |
||
| 114 | '[i]', |
||
| 115 | '[/i]', |
||
| 116 | '[u]', |
||
| 117 | '[/u]', |
||
| 118 | '[url]', |
||
| 119 | '[/url]', |
||
| 120 | '[url=$1]', |
||
| 121 | '[/url]', |
||
| 122 | '[url=$2]$3[/url]', |
||
| 123 | '[img]', |
||
| 124 | '[/img]', |
||
| 125 | '[size=' . percent_to_px("\1") . 'px]', |
||
|
|
|||
| 126 | '[/size]', |
||
| 127 | '[color=$1]', |
||
| 128 | '[/color]', |
||
| 129 | '[code=$1]', |
||
| 130 | '[code]', |
||
| 131 | '[/code]', |
||
| 132 | '[list type=$1]', |
||
| 133 | '[list]', |
||
| 134 | '[/list]', |
||
| 135 | '[li]', |
||
| 136 | '[/li]', |
||
| 137 | '$2', |
||
| 138 | ), $message); |
||
| 139 | |||
| 140 | $message = preg_replace('~\[size=(.+?)px\]~is', "[size=" . ('\1' > '99' ? 99 : '"\1"') . "px]", $message); |
||
| 141 | |||
| 142 | $message = strtr($message, array( |
||
| 143 | '[list type=1]' => '[list type=decimal]', |
||
| 144 | '[list type=a]' => '[list type=lower-alpha]', |
||
| 145 | )); |
||
| 146 | |||
| 147 | return stripslashes($message); |
||
| 148 | } |