Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.
Common duplication problems, and corresponding solutions are:
| 1 | <?php |
||
| 4 | class Kint_Renderer_Cli extends Kint_Renderer_Text |
||
| 5 | { |
||
| 6 | /** |
||
| 7 | * @var bool enable colors when Kint is run in *UNIX* command line |
||
| 8 | */ |
||
| 9 | public static $cli_colors = true; |
||
| 10 | |||
| 11 | /** |
||
| 12 | * Forces utf8 output on windows. |
||
| 13 | * |
||
| 14 | * @var bool |
||
| 15 | */ |
||
| 16 | public static $force_utf8 = false; |
||
| 17 | |||
| 18 | /** |
||
| 19 | * Detects the terminal width on startup. |
||
| 20 | * |
||
| 21 | * @var bool |
||
| 22 | */ |
||
| 23 | public static $detect_width = true; |
||
| 24 | |||
| 25 | /** |
||
| 26 | * The minimum width to detect terminal size as. |
||
| 27 | * |
||
| 28 | * Less than this is ignored and falls back to default width. |
||
| 29 | * |
||
| 30 | * @var int |
||
| 31 | */ |
||
| 32 | public static $min_terminal_width = 40; |
||
| 33 | |||
| 34 | protected static $terminal_width = null; |
||
| 35 | |||
| 36 | protected $windows_output = false; |
||
| 37 | |||
| 38 | public function __construct(array $params = array()) |
||
| 58 | |||
| 59 | View Code Duplication | protected function utf8_to_windows($string) |
|
| 67 | |||
| 68 | View Code Duplication | public function colorValue($string) |
|
| 76 | |||
| 77 | View Code Duplication | public function colorType($string) |
|
| 85 | |||
| 86 | View Code Duplication | public function colorTitle($string) |
|
| 94 | |||
| 95 | public function renderTitle(Kint_Object $o) |
||
| 103 | |||
| 104 | public function preRender() |
||
| 108 | |||
| 109 | public function postRender() |
||
| 117 | |||
| 118 | public function escape($string, $encoding = false) |
||
| 122 | } |
||
| 123 |
This check examines a number of code elements and verifies that they conform to the given naming conventions.
You can set conventions for local variables, abstract classes, utility classes, constant, properties, methods, parameters, interfaces, classes, exceptions and special methods.