| Conditions | 15 |
| Paths | 11 |
| Total Lines | 57 |
| Code Lines | 30 |
| Lines | 20 |
| Ratio | 35.09 % |
| Changes | 1 | ||
| Bugs | 1 | 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 |
||
| 100 | public function addHighlighting() |
||
| 101 | { |
||
| 102 | $styledColumns = []; |
||
| 103 | foreach ($this->rows as $column) |
||
| 104 | { |
||
| 105 | $styledColumn = $column; |
||
| 106 | if (is_array($column)) |
||
| 107 | { |
||
| 108 | // Highlighting for data table column types and audit. |
||
| 109 | if (!empty($column['data_table_type'])) |
||
| 110 | { |
||
| 111 | if (isset($column['data_table_type']) && !isset($column['audit_table_type'])) |
||
| 112 | { |
||
| 113 | $styledColumn['column_name'] = sprintf('<mm_column>%s</>', $styledColumn['column_name']); |
||
| 114 | $styledColumn['data_table_type'] = sprintf('<mm_type>%s</>', $styledColumn['data_table_type']); |
||
| 115 | } |
||
| 116 | View Code Duplication | else if (!isset($column['data_table_type']) && isset($column['audit_table_type'])) |
|
| 117 | { |
||
| 118 | $styledColumn['audit_table_type'] = sprintf('<mm_type>%s</>', $styledColumn['audit_table_type']); |
||
| 119 | } |
||
| 120 | else if (strcmp($column['data_table_type'], $column['audit_table_type'])) |
||
| 121 | { |
||
| 122 | $styledColumn['column_name'] = sprintf('<mm_column>%s</>', $styledColumn['column_name']); |
||
| 123 | $styledColumn['data_table_type'] = sprintf('<mm_type>%s</>', $styledColumn['data_table_type']); |
||
| 124 | $styledColumn['audit_table_type'] = sprintf('<mm_type>%s</>', $styledColumn['audit_table_type']); |
||
| 125 | } |
||
| 126 | } |
||
| 127 | else |
||
| 128 | { |
||
| 129 | // Highlighting for audit table column types and audit_columns in config file. |
||
| 130 | $searchColumn = StaticDataLayer::searchInRowSet('column_name', $styledColumn['column_name'], $this->auditColumns); |
||
| 131 | if (isset($searchColumn)) |
||
| 132 | { |
||
| 133 | $configType = $this->auditColumns[$searchColumn]['column_type']; |
||
| 134 | if (isset($configType) && !isset($column['audit_table_type'])) |
||
| 135 | { |
||
| 136 | $styledColumn['column_name'] = sprintf('<mm_column>%s</>', $styledColumn['column_name']); |
||
| 137 | $styledColumn['config_type'] = sprintf('<mm_type>%s</>', $styledColumn['config_type']); |
||
| 138 | } |
||
| 139 | View Code Duplication | else if (!isset($configType) && isset($column['audit_table_type'])) |
|
| 140 | { |
||
| 141 | $styledColumn['audit_table_type'] = sprintf('<mm_type>%s</>', $column['audit_table_type']); |
||
| 142 | } |
||
| 143 | else if (strcmp($configType, $column['audit_table_type'])) |
||
| 144 | { |
||
| 145 | $styledColumn['column_name'] = sprintf('<mm_column>%s</>', $styledColumn['column_name']); |
||
| 146 | $styledColumn['audit_table_type'] = sprintf('<mm_type>%s</>', $column['audit_table_type']); |
||
| 147 | $styledColumn['config_type'] = sprintf('<mm_type>%s</>', $styledColumn['config_type']); |
||
| 148 | } |
||
| 149 | } |
||
| 150 | } |
||
| 151 | } |
||
| 152 | $styledColumns[] = $styledColumn; |
||
| 153 | } |
||
| 154 | |||
| 155 | $this->rows = $styledColumns; |
||
| 156 | } |
||
| 157 | |||
| 173 |
This check compares the return type specified in the
@returnannotation of a function or method doc comment with the types returned by the function and raises an issue if they mismatch.