| Conditions | 18 | 
| Paths | 13824 | 
| Total Lines | 89 | 
| Code Lines | 54 | 
| Lines | 13 | 
| Ratio | 14.61 % | 
| 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  | 
            ||
| 70 | public function send($severity, $msg)  | 
            ||
| 71 |     { | 
            ||
| 72 | $args = array();  | 
            ||
| 73 |         if (func_num_args() > 2) { | 
            ||
| 74 | $args = func_get_args();  | 
            ||
| 75 | array_shift($args);  | 
            ||
| 76 | unset($args[0]);  | 
            ||
| 77 | }  | 
            ||
| 78 | |||
| 79 |         $token = $this->context->get('CurrentToken', true); | 
            ||
| 80 |         $line  = $token ? $token->line : $this->context->get('CurrentLine', true); | 
            ||
| 81 |         $col   = $token ? $token->col  : $this->context->get('CurrentCol', true); | 
            ||
| 82 |         $attr  = $this->context->get('CurrentAttr', true); | 
            ||
| 83 | |||
| 84 | // perform special substitutions, also add custom parameters  | 
            ||
| 85 | $subst = array();  | 
            ||
| 86 |         if (!is_null($token)) { | 
            ||
| 87 | $args['CurrentToken'] = $token;  | 
            ||
| 88 | }  | 
            ||
| 89 |         if (!is_null($attr)) { | 
            ||
| 90 | $subst['$CurrentAttr.Name'] = $attr;  | 
            ||
| 91 |             if (isset($token->attr[$attr])) { | 
            ||
| 92 | $subst['$CurrentAttr.Value'] = $token->attr[$attr];  | 
            ||
| 93 | }  | 
            ||
| 94 | }  | 
            ||
| 95 | |||
| 96 |         if (empty($args)) { | 
            ||
| 97 | $msg = $this->locale->getMessage($msg);  | 
            ||
| 98 |         } else { | 
            ||
| 99 | $msg = $this->locale->formatMessage($msg, $args);  | 
            ||
| 100 | }  | 
            ||
| 101 | |||
| 102 |         if (!empty($subst)) { | 
            ||
| 103 | $msg = strtr($msg, $subst);  | 
            ||
| 104 | }  | 
            ||
| 105 | |||
| 106 | // (numerically indexed)  | 
            ||
| 107 | $error = array(  | 
            ||
| 108 | self::LINENO => $line,  | 
            ||
| 109 | self::SEVERITY => $severity,  | 
            ||
| 110 | self::MESSAGE => $msg,  | 
            ||
| 111 | self::CHILDREN => array()  | 
            ||
| 112 | );  | 
            ||
| 113 | $this->_current[] = $error;  | 
            ||
| 114 | |||
| 115 | // NEW CODE BELOW ...  | 
            ||
| 116 | // Top-level errors are either:  | 
            ||
| 117 | // TOKEN type, if $value is set appropriately, or  | 
            ||
| 118 | // "syntax" type, if $value is null  | 
            ||
| 119 | $new_struct = new HTMLPurifier_ErrorStruct();  | 
            ||
| 120 | $new_struct->type = HTMLPurifier_ErrorStruct::TOKEN;  | 
            ||
| 121 |         if ($token) { | 
            ||
| 122 | $new_struct->value = clone $token;  | 
            ||
| 123 | }  | 
            ||
| 124 |         if (is_int($line) && is_int($col)) { | 
            ||
| 125 |             if (isset($this->lines[$line][$col])) { | 
            ||
| 126 | $struct = $this->lines[$line][$col];  | 
            ||
| 127 |             } else { | 
            ||
| 128 | $struct = $this->lines[$line][$col] = $new_struct;  | 
            ||
| 129 | }  | 
            ||
| 130 | // These ksorts may present a performance problem  | 
            ||
| 131 | ksort($this->lines[$line], SORT_NUMERIC);  | 
            ||
| 132 |         } else { | 
            ||
| 133 |             if (isset($this->lines[-1])) { | 
            ||
| 134 | $struct = $this->lines[-1];  | 
            ||
| 135 |             } else { | 
            ||
| 136 | $struct = $this->lines[-1] = $new_struct;  | 
            ||
| 137 | }  | 
            ||
| 138 | }  | 
            ||
| 139 | ksort($this->lines, SORT_NUMERIC);  | 
            ||
| 140 | |||
| 141 | // Now, check if we need to operate on a lower structure  | 
            ||
| 142 | View Code Duplication |         if (!empty($attr)) { | 
            |
| 143 | $struct = $struct->getChild(HTMLPurifier_ErrorStruct::ATTR, $attr);  | 
            ||
| 144 |             if (!$struct->value) { | 
            ||
| 145 | $struct->value = array($attr, 'PUT VALUE HERE');  | 
            ||
| 146 | }  | 
            ||
| 147 | }  | 
            ||
| 148 | View Code Duplication |         if (!empty($cssprop)) { | 
            |
| 149 | $struct = $struct->getChild(HTMLPurifier_ErrorStruct::CSSPROP, $cssprop);  | 
            ||
| 150 |             if (!$struct->value) { | 
            ||
| 151 | // if we tokenize CSS this might be a little more difficult to do  | 
            ||
| 152 | $struct->value = array($cssprop, 'PUT VALUE HERE');  | 
            ||
| 153 | }  | 
            ||
| 154 | }  | 
            ||
| 155 | |||
| 156 | // Ok, structs are all setup, now time to register the error  | 
            ||
| 157 | $struct->addError($severity, $msg);  | 
            ||
| 158 | }  | 
            ||
| 159 | |||
| 245 | 
You can fix this by adding a namespace to your class:
When choosing a vendor namespace, try to pick something that is not too generic to avoid conflicts with other libraries.