| Conditions | 9 |
| Paths | 27 |
| Total Lines | 63 |
| Code Lines | 31 |
| 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 |
||
| 103 | public function store($table) |
||
| 104 | { |
||
| 105 | $dataObject = $this->getDataObject($table); |
||
| 106 | $historyTable = Table::getInstance('Contenthistory', 'JTable'); |
||
| 107 | $typeTable = Table::getInstance('Contenttype', 'JTable'); |
||
| 108 | $typeTable->load(array('type_alias' => $this->typeAlias)); |
||
| 109 | $historyTable->set('ucm_type_id', $typeTable->type_id); |
||
| 110 | |||
| 111 | $key = $table->getKeyName(); |
||
| 112 | $historyTable->set('ucm_item_id', $table->$key); |
||
| 113 | |||
| 114 | // Don't store unless we have a non-zero item id |
||
| 115 | if (!$historyTable->ucm_item_id) |
||
| 116 | { |
||
| 117 | return true; |
||
| 118 | } |
||
| 119 | |||
| 120 | $historyTable->set('version_data', json_encode($dataObject)); |
||
| 121 | $input = \JFactory::getApplication()->input; |
||
| 122 | $data = $input->get('jform', array(), 'array'); |
||
| 123 | $versionName = false; |
||
| 124 | |||
| 125 | if (isset($data['version_note'])) |
||
| 126 | { |
||
| 127 | $versionName = \JFilterInput::getInstance()->clean($data['version_note'], 'string'); |
||
| 128 | $historyTable->set('version_note', $versionName); |
||
| 129 | } |
||
| 130 | |||
| 131 | // Don't save if hash already exists and same version note |
||
| 132 | $historyTable->set('sha1_hash', $historyTable->getSha1($dataObject, $typeTable)); |
||
| 133 | |||
| 134 | if ($historyRow = $historyTable->getHashMatch()) |
||
| 135 | { |
||
| 136 | if (!$versionName || ($historyRow->version_note === $versionName)) |
||
| 137 | { |
||
| 138 | return true; |
||
| 139 | } |
||
| 140 | else |
||
| 141 | { |
||
| 142 | // Update existing row to set version note |
||
| 143 | $historyTable->set('version_id', $historyRow->version_id); |
||
| 144 | } |
||
| 145 | } |
||
| 146 | |||
| 147 | $result = $historyTable->store(); |
||
| 148 | |||
| 149 | // Load history_limit config from extension. |
||
| 150 | $aliasParts = explode('.', $this->typeAlias); |
||
| 151 | |||
| 152 | $context = isset($aliasParts[1]) ? $aliasParts[1] : ''; |
||
| 153 | |||
| 154 | $maxVersionsContext = ComponentHelper::getParams($aliasParts[0])->get('history_limit' . '_' . $context, 0); |
||
| 155 | |||
| 156 | if ($maxVersionsContext) |
||
| 157 | { |
||
| 158 | $historyTable->deleteOldVersions($maxVersionsContext); |
||
| 159 | } |
||
| 160 | elseif ($maxVersions = ComponentHelper::getParams($aliasParts[0])->get('history_limit', 0)) |
||
| 161 | { |
||
| 162 | $historyTable->deleteOldVersions($maxVersions); |
||
| 163 | } |
||
| 164 | |||
| 165 | return $result; |
||
| 166 | } |
||
| 168 |
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths