| Conditions | 3 |
| Paths | 4 |
| Total Lines | 60 |
| Code Lines | 42 |
| 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 |
||
| 12 | public function blobProvider() |
||
| 13 | { |
||
| 14 | $p = new Parser(); |
||
|
|
|||
| 15 | $b = BasicObject::blank('$v'); |
||
| 16 | |||
| 17 | BlobObject::$char_encodings = array( |
||
| 18 | 'ASCII', |
||
| 19 | 'UTF-8', |
||
| 20 | ); |
||
| 21 | |||
| 22 | $strings = array( |
||
| 23 | 'empty' => array( |
||
| 24 | '', |
||
| 25 | 'ASCII', |
||
| 26 | 'string', |
||
| 27 | ), |
||
| 28 | 'ASCII' => array( |
||
| 29 | "The quick brown fox jumps<br>\r\n\tover the lazy dog", |
||
| 30 | 'ASCII', |
||
| 31 | 'string', |
||
| 32 | ), |
||
| 33 | 'UTF-8' => array( |
||
| 34 | "El zorro marrón rápido salta sobre<br>\r\n\tel perro perezoso", |
||
| 35 | 'UTF-8', |
||
| 36 | 'UTF-8 string', |
||
| 37 | ), |
||
| 38 | 'fail' => array( |
||
| 39 | "The quick brown fox jumps<br>\r\n\tover the lazy dog\x90\x1b", |
||
| 40 | false, |
||
| 41 | 'binary string', |
||
| 42 | ), |
||
| 43 | ); |
||
| 44 | |||
| 45 | if (!defined('HHVM_VERSION')) { |
||
| 46 | BlobObject::$char_encodings[] = 'SJIS'; |
||
| 47 | BlobObject::$char_encodings[] = 'EUC-JP'; |
||
| 48 | BlobObject::$char_encodings[] = 'Windows-1252'; |
||
| 49 | $strings['SJIS'] = array( |
||
| 50 | mb_convert_encoding("キント最強<br>\r\n\tASCII", 'SJIS', 'UTF-8'), |
||
| 51 | 'SJIS', |
||
| 52 | 'SJIS string', |
||
| 53 | ); |
||
| 54 | $strings['EUC-JP'] = array( |
||
| 55 | mb_convert_encoding("キント最強<br>\r\n\tASCII", 'EUC-JP', 'UTF-8'), |
||
| 56 | 'EUC-JP', |
||
| 57 | 'EUC-JP string', |
||
| 58 | ); |
||
| 59 | $strings['yuck'] = array( |
||
| 60 | mb_convert_encoding("El zorro marrón rápido salta sobre<br>\r\n\tel perro perezoso", 'Windows-1252', 'UTF-8'), |
||
| 61 | 'Windows-1252', |
||
| 62 | 'Windows-1252 string', |
||
| 63 | ); |
||
| 64 | } |
||
| 65 | |||
| 66 | foreach ($strings as $encoding => &$string) { |
||
| 67 | array_unshift($string, $p->parse($string[0], clone $b)); |
||
| 68 | } |
||
| 69 | |||
| 70 | return $strings; |
||
| 71 | } |
||
| 72 | |||
| 220 |
Short variable names may make your code harder to understand. Variable names should be self-descriptive. This check looks for variable names who are shorter than a configured minimum.