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