Conditions | 18 |
Paths | 516 |
Total Lines | 50 |
Code Lines | 29 |
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 | $timestamp = $this->unixTimestamp === true ? strtotime(date('Y-m-d H:i:s')) : date('Y-m-d H:i:s'); |
||
79 | |||
80 | if ( ! isset($sets[ 'record_status' ])) { |
||
81 | $sets[ 'record_status' ] = $this->recordStatus; |
||
82 | } |
||
83 | |||
84 | if (empty($this->primaryKeys)) { |
||
85 | $primaryKey = isset($this->primaryKey) ? $this->primaryKey : 'id'; |
||
86 | |||
87 | if (isset($sets[ $primaryKey ])) { |
||
88 | if (empty($sets[ $primaryKey ])) { |
||
89 | unset($sets[ $primaryKey ]); |
||
90 | } |
||
91 | } |
||
92 | |||
93 | if (empty($sets[ $primaryKey ])) { |
||
94 | if ( ! isset($sets[ 'record_create_user' ])) { |
||
95 | $sets[ 'record_create_user' ] = $this->recordUser; |
||
96 | } |
||
97 | |||
98 | if ( ! isset($sets[ 'record_create_timestamp' ])) { |
||
99 | $sets[ 'record_create_timestamp' ] = $timestamp; |
||
100 | } elseif ($this->unixTimestamp) { |
||
101 | $sets[ 'record_create_timestamp' ] = strtotime($sets[ 'record_create_timestamp' ]); |
||
102 | } |
||
103 | } |
||
104 | } else { |
||
105 | foreach ($this->primaryKeys as $primaryKey) { |
||
106 | if (empty($sets[ $primaryKey ])) { |
||
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 | } elseif ($this->unixTimestamp) { |
||
114 | $sets[ 'record_create_timestamp' ] = strtotime($sets[ 'record_create_timestamp' ]); |
||
115 | } |
||
116 | } |
||
117 | } |
||
118 | } |
||
119 | |||
120 | $sets[ 'record_update_user' ] = $this->recordUser; |
||
121 | |||
122 | if ( ! isset($sets[ 'record_update_timestamp' ])) { |
||
123 | $sets[ 'record_update_timestamp' ] = $timestamp; |
||
124 | } elseif ($this->unixTimestamp) { |
||
125 | $sets[ 'record_update_timestamp' ] = strtotime($sets[ 'record_update_timestamp' ]); |
||
126 | } |
||
152 | } |