Conditions | 1 |
Paths | 1 |
Total Lines | 79 |
Code Lines | 53 |
Lines | 0 |
Ratio | 0 % |
Changes | 8 | ||
Bugs | 0 | Features | 2 |
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 |
||
112 | public function behaviors() |
||
113 | { |
||
114 | return [ |
||
115 | [ |
||
116 | 'class' => TimestampBehavior::className(), |
||
117 | 'createdAtAttribute' => 'date_create', |
||
118 | 'updatedAtAttribute' => 'date_update', |
||
119 | 'value' => new \yii\db\Expression('NOW()'), |
||
120 | ], |
||
121 | |||
122 | [ |
||
123 | 'class' => 'creocoder\taggable\TaggableBehavior', |
||
124 | // 'tagValuesAsArray' => false, |
||
125 | // 'tagRelation' => 'tags', |
||
126 | 'tagValueAttribute' => 'title', |
||
127 | 'tagFrequencyAttribute' => 'count', |
||
128 | ], |
||
129 | |||
130 | [ |
||
131 | 'class' => 'rkit\filemanager\behaviors\FileBehavior', |
||
132 | 'attributes' => [ |
||
133 | 'text' => [ |
||
134 | 'storage' => 'rkit\filemanager\storages\LocalStorage', |
||
135 | 'rules' => [ |
||
136 | 'mimeTypes' => ['image/png', 'image/jpg', 'image/jpeg'], |
||
137 | 'extensions' => ['jpg', 'jpeg', 'png'], |
||
138 | 'maxSize' => 1024 * 1024 * 1, // 1 MB |
||
139 | 'tooBig' => Yii::t('app', 'File size must not exceed') . ' 1Mb' |
||
140 | ] |
||
141 | ], |
||
142 | 'preview' => [ |
||
143 | 'storage' => 'rkit\filemanager\storages\LocalStorage', |
||
144 | 'saveFilePath' => true, |
||
145 | 'rules' => [ |
||
146 | 'imageSize' => ['minWidth' => 300, 'minHeight' => 300], |
||
147 | 'mimeTypes' => ['image/png', 'image/jpg', 'image/jpeg'], |
||
148 | 'extensions' => ['jpg', 'jpeg', 'png'], |
||
149 | 'maxSize' => 1024 * 1024 * 1, // 1 MB |
||
150 | 'tooBig' => Yii::t('app', 'File size must not exceed') . ' 1Mb' |
||
151 | ], |
||
152 | 'preset' => [ |
||
153 | '200x200' => function ($realPath, $publicPath, $thumbPath) { |
||
154 | Image::make($realPath . $publicPath) |
||
155 | ->fit(200, 200) |
||
156 | ->save($realPath . $thumbPath, 100); |
||
157 | }, |
||
158 | '1000x1000' => function ($realPath, $publicPath, $thumbPath) { |
||
159 | Image::make($realPath . $publicPath) |
||
160 | ->resize(1000, 1000, function ($constraint) { |
||
161 | $constraint->aspectRatio(); |
||
162 | $constraint->upsize(); |
||
163 | }) |
||
164 | ->save(null, 100); |
||
165 | }, |
||
166 | ], |
||
167 | 'applyPresetAfterUpload' => '*' |
||
168 | ], |
||
169 | 'gallery' => [ |
||
170 | 'storage' => 'rkit\filemanager\storages\LocalStorage', |
||
171 | 'multiple' => true, |
||
172 | 'rules' => [ |
||
173 | 'imageSize' => ['minWidth' => 300, 'minHeight' => 300], |
||
174 | 'mimeTypes' => ['image/png', 'image/jpg', 'image/jpeg'], |
||
175 | 'extensions' => ['jpg', 'jpeg', 'png'], |
||
176 | 'maxSize' => 1024 * 1024 * 1, // 1 MB |
||
177 | 'tooBig' => Yii::t('app', 'File size must not exceed') . ' 1Mb' |
||
178 | ], |
||
179 | 'preset' => [ |
||
180 | '80x80' => function ($realPath, $publicPath, $thumbPath) { |
||
181 | Image::make($realPath . $publicPath) |
||
182 | ->fit(80, 80) |
||
183 | ->save($realPath . $thumbPath, 100); |
||
184 | }, |
||
185 | ], |
||
186 | ] |
||
187 | ] |
||
188 | ] |
||
189 | ]; |
||
190 | } |
||
191 | |||
260 |