| Conditions | 23 |
| Paths | 6192 |
| Total Lines | 62 |
| Code Lines | 35 |
| 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 |
||
| 97 | protected function insertRecordSets(array &$sets) |
||
| 98 | { |
||
| 99 | $timestamp = $this->unixTimestamp === true ? strtotime(date('Y-m-d H:i:s')) : date('Y-m-d H:i:s'); |
||
| 100 | |||
| 101 | if(is_null($this->recordUser)) { |
||
| 102 | if(globals()->offsetExists('account')) { |
||
| 103 | $this->setRecordUser(globals()->account->id); |
||
| 104 | } |
||
| 105 | } |
||
| 106 | |||
| 107 | if ( ! isset($sets[ 'record_status' ])) { |
||
| 108 | $sets[ 'record_status' ] = $this->recordStatus; |
||
| 109 | } |
||
| 110 | |||
| 111 | if (empty($this->primaryKeys)) { |
||
| 112 | $primaryKey = isset($this->primaryKey) ? $this->primaryKey : 'id'; |
||
| 113 | |||
| 114 | if (isset($sets[ $primaryKey ])) { |
||
| 115 | if (empty($sets[ $primaryKey ])) { |
||
| 116 | unset($sets[ $primaryKey ]); |
||
| 117 | } |
||
| 118 | } |
||
| 119 | |||
| 120 | if (empty($sets[ $primaryKey ])) { |
||
| 121 | if ( ! isset($sets[ 'record_create_user' ])) { |
||
| 122 | $sets[ 'record_create_user' ] = $this->recordUser; |
||
| 123 | } |
||
| 124 | |||
| 125 | if ( ! isset($sets[ 'record_create_timestamp' ])) { |
||
| 126 | $sets[ 'record_create_timestamp' ] = $timestamp; |
||
| 127 | } elseif ($this->unixTimestamp) { |
||
| 128 | $sets[ 'record_create_timestamp' ] = strtotime($sets[ 'record_create_timestamp' ]); |
||
| 129 | } |
||
| 130 | } |
||
| 131 | } else { |
||
| 132 | foreach ($this->primaryKeys as $primaryKey) { |
||
| 133 | if (empty($sets[ $primaryKey ])) { |
||
| 134 | if ( ! isset($sets[ 'record_create_user' ])) { |
||
| 135 | $sets[ 'record_create_user' ] = $this->recordUser; |
||
| 136 | } |
||
| 137 | |||
| 138 | if ( ! isset($sets[ 'record_create_timestamp' ])) { |
||
| 139 | $sets[ 'record_create_timestamp' ] = $timestamp; |
||
| 140 | } elseif ($this->unixTimestamp) { |
||
| 141 | $sets[ 'record_create_timestamp' ] = strtotime($sets[ 'record_create_timestamp' ]); |
||
| 142 | } |
||
| 143 | } |
||
| 144 | } |
||
| 145 | } |
||
| 146 | |||
| 147 | if ( ! isset($sets[ 'record_update_user' ])) { |
||
| 148 | $sets[ 'record_update_user' ] = $this->recordUser; |
||
| 149 | } |
||
| 150 | |||
| 151 | if ( ! isset($sets[ 'record_update_timestamp' ])) { |
||
| 152 | $sets[ 'record_update_timestamp' ] = $timestamp; |
||
| 153 | } elseif ($this->unixTimestamp) { |
||
| 154 | $sets[ 'record_update_timestamp' ] = strtotime($sets[ 'record_update_timestamp' ]); |
||
| 155 | } |
||
| 156 | |||
| 157 | if ( ! isset($sets[ 'record_ordering' ]) && $this->recordOrdering === true) { |
||
| 158 | $sets[ 'record_ordering' ] = $this->getRecordOrdering(); |
||
| 159 | } |
||
| 207 | } |