Complex classes like AbstractMedium often do a lot of different things. To break such a class down, we need to identify a cohesive component within that class. A common approach to find such a component is to look for fields/methods that share the same prefixes, or suffixes.
Once you have determined the fields that belong together, you can apply the Extract Class refactoring. If the component makes sense as a sub-class, Extract Subclass is also a candidate, and is often faster.
While breaking up the class, it is a good idea to analyze how other classes use AbstractMedium, and based on these observations, apply Extract Interface, too.
| 1 | <?php |
||
| 20 | abstract class AbstractMedium implements ModelInterface |
||
| 21 | { |
||
| 22 | protected $id; |
||
| 23 | |||
| 24 | protected $mimeType; |
||
| 25 | |||
| 26 | protected $path; |
||
| 27 | |||
| 28 | protected $extname; |
||
| 29 | |||
| 30 | protected $duration; |
||
| 31 | |||
| 32 | protected $width; |
||
| 33 | |||
| 34 | protected $height; |
||
| 35 | |||
| 36 | protected $fileSize; |
||
| 37 | |||
| 38 | protected $videoBitrate; |
||
| 39 | |||
| 40 | protected $audioBitrate; |
||
| 41 | |||
| 42 | protected $audioCodec; |
||
| 43 | |||
| 44 | protected $videoCodec; |
||
| 45 | |||
| 46 | protected $fps; |
||
| 47 | |||
| 48 | protected $audioChannels; |
||
| 49 | |||
| 50 | protected $audioSampleRate; |
||
| 51 | |||
| 52 | protected $status; |
||
| 53 | |||
| 54 | protected $errorMessage; |
||
| 55 | |||
| 56 | protected $errorClass; |
||
| 57 | |||
| 58 | protected $createdAt; |
||
| 59 | |||
| 60 | protected $updatedAt; |
||
| 61 | |||
| 62 | public function getId() |
||
| 66 | |||
| 67 | public function setId($id) |
||
| 71 | |||
| 72 | public function getMimeType() |
||
| 76 | |||
| 77 | public function setMimeType($mimeType) |
||
| 81 | |||
| 82 | public function getPath() |
||
| 86 | |||
| 87 | public function setPath($path) |
||
| 91 | |||
| 92 | public function getExtname() |
||
| 96 | |||
| 97 | public function setExtname($extname) |
||
| 101 | |||
| 102 | public function getDuration() |
||
| 106 | |||
| 107 | public function setDuration($duration) |
||
| 111 | |||
| 112 | public function getWidth() |
||
| 116 | |||
| 117 | public function setWidth($width) |
||
| 121 | |||
| 122 | public function getHeight() |
||
| 126 | |||
| 127 | public function setHeight($height) |
||
| 131 | |||
| 132 | public function getFileSize() |
||
| 136 | |||
| 137 | public function setFileSize($fileSize) |
||
| 141 | |||
| 142 | public function getVideoBitrate() |
||
| 146 | |||
| 147 | public function setVideoBitrate($videoBitrate) |
||
| 151 | |||
| 152 | public function getAudioBitrate() |
||
| 156 | |||
| 157 | public function setAudioBitrate($audioBitrate) |
||
| 161 | |||
| 162 | public function getAudioCodec() |
||
| 166 | |||
| 167 | public function setAudioCodec($audioCodec) |
||
| 171 | |||
| 172 | public function getVideoCodec() |
||
| 176 | |||
| 177 | public function setVideoCodec($videoCodec) |
||
| 181 | |||
| 182 | public function getFps() |
||
| 186 | |||
| 187 | public function setFps($fps) |
||
| 191 | |||
| 192 | public function getAudioChannels() |
||
| 196 | |||
| 197 | public function setAudioChannels($audioChannels) |
||
| 201 | |||
| 202 | public function getAudioSampleRate() |
||
| 206 | |||
| 207 | public function setAudioSampleRate($audioSampleRate) |
||
| 211 | |||
| 212 | public function getStatus() |
||
| 216 | |||
| 217 | public function setStatus($status) |
||
| 221 | |||
| 222 | public function getErrorMessage() |
||
| 226 | |||
| 227 | public function setErrorMessage($errorMessage) |
||
| 231 | |||
| 232 | public function getErrorClass() |
||
| 236 | |||
| 237 | public function setErrorClass($errorClass) |
||
| 241 | |||
| 242 | public function getCreatedAt() |
||
| 246 | |||
| 247 | public function setCreatedAt($createdAt) |
||
| 251 | |||
| 252 | public function getUpdatedAt() |
||
| 256 | |||
| 257 | public function setUpdatedAt($updatedAt) |
||
| 261 | } |
||
| 262 |