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 |
||
76 | protected function insertRecordSets(array &$sets) |
||
77 | { |
||
78 | if (is_null($this->recordUser) and function_exists('globals')) { |
||
|
|||
79 | if ($account = globals()->offsetGet('account')) { |
||
80 | $this->recordUser = isset($account->id_user_account) |
||
81 | ? $account->id_user_account |
||
82 | : $account->id; |
||
83 | } |
||
84 | } |
||
85 | |||
86 | $timestamp = $this->unixTimestamp === true ? strtotime(date('Y-m-d H:i:s')) : date('Y-m-d H:i:s'); |
||
87 | |||
88 | if ( ! isset($sets[ 'record_status' ])) { |
||
89 | $sets[ 'record_status' ] = $this->recordStatus; |
||
90 | } |
||
91 | |||
92 | if (empty($this->primary_keys)) { |
||
93 | $primary_key = isset($this->primary_key) ? $this->primary_key : 'id'; |
||
94 | |||
95 | if (empty($sets[ $primary_key ])) { |
||
96 | if ( ! isset($sets[ 'record_create_user' ])) { |
||
97 | $sets[ 'record_create_user' ] = $this->recordUser; |
||
98 | } |
||
99 | |||
100 | if ( ! isset($sets[ 'record_create_timestamp' ])) { |
||
101 | $sets[ 'record_create_timestamp' ] = $timestamp; |
||
102 | } |
||
103 | } |
||
104 | } else { |
||
105 | foreach ($this->primary_keys as $primary_key) { |
||
106 | if (empty($sets[ $primary_key ])) { |
||
107 | if ( ! isset($sets[ 'record_create_user' ])) { |
||
108 | $sets[ 'record_create_user' ] = $this->recordUser; |
||
109 | } |
||
110 | |||
111 | if ( ! isset($sets[ 'record_create_timestamp' ])) { |
||
112 | $sets[ 'record_create_timestamp' ] = $timestamp; |
||
113 | } |
||
114 | } |
||
115 | } |
||
116 | } |
||
117 | |||
118 | $sets[ 'record_update_user' ] = $this->recordUser; |
||
119 | |||
120 | if ( ! isset($sets[ 'record_update_timestamp' ])) { |
||
121 | $sets[ 'record_update_timestamp' ] = $timestamp; |
||
122 | } |
||
153 | } |