| Conditions | 17 |
| Paths | 352 |
| Total Lines | 46 |
| Code Lines | 25 |
| 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 |
||
| 86 | protected function insertRecordSets(array &$sets) |
||
| 87 | { |
||
| 88 | if (is_null($this->recordUser) and function_exists('globals')) { |
||
|
|
|||
| 89 | if ($account = globals()->offsetGet('account')) { |
||
| 90 | $this->recordUser = isset($account->id_user_account) |
||
| 91 | ? $account->id_user_account |
||
| 92 | : $account->id; |
||
| 93 | } |
||
| 94 | } |
||
| 95 | |||
| 96 | $timestamp = $this->isUnixTimestamp === true ? strtotime(date('Y-m-d H:i:s')) : date('Y-m-d H:i:s'); |
||
| 97 | |||
| 98 | if ( ! isset($sets[ 'record_status' ])) { |
||
| 99 | $sets[ 'record_status' ] = $this->recordStatus; |
||
| 100 | } |
||
| 101 | |||
| 102 | if (empty($this->primary_keys)) { |
||
| 103 | $primary_key = isset($this->primary_key) ? $this->primary_key : 'id'; |
||
| 104 | |||
| 105 | if (empty($sets[ $primary_key ])) { |
||
| 106 | if ( ! isset($sets[ 'record_create_user' ])) { |
||
| 107 | $sets[ 'record_create_user' ] = $this->recordUser; |
||
| 108 | } |
||
| 109 | |||
| 110 | if ( ! isset($sets[ 'record_create_timestamp' ])) { |
||
| 111 | $sets[ 'record_create_timestamp' ] = $timestamp; |
||
| 112 | } |
||
| 113 | } |
||
| 114 | } else { |
||
| 115 | foreach ($this->primary_keys as $primary_key) { |
||
| 116 | if (empty($sets[ $primary_key ])) { |
||
| 117 | if ( ! isset($sets[ 'record_create_user' ])) { |
||
| 118 | $sets[ 'record_create_user' ] = $this->recordUser; |
||
| 119 | } |
||
| 120 | |||
| 121 | if ( ! isset($sets[ 'record_create_timestamp' ])) { |
||
| 122 | $sets[ 'record_create_timestamp' ] = $timestamp; |
||
| 123 | } |
||
| 124 | } |
||
| 125 | } |
||
| 126 | } |
||
| 127 | |||
| 128 | $sets[ 'record_update_user' ] = $this->recordUser; |
||
| 129 | |||
| 130 | if ( ! isset($sets[ 'record_update_timestamp' ])) { |
||
| 131 | $sets[ 'record_update_timestamp' ] = $timestamp; |
||
| 132 | } |
||
| 156 | } |