Complex classes like Profile 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 Profile, and based on these observations, apply Extract Interface, too.
| 1 | <?php |
||
| 19 | class Profile implements ModelInterface |
||
| 20 | { |
||
| 21 | private $id; |
||
| 22 | |||
| 23 | private $title; |
||
| 24 | |||
| 25 | private $name; |
||
| 26 | |||
| 27 | private $presetName; |
||
| 28 | |||
| 29 | private $extname; |
||
| 30 | |||
| 31 | private $width; |
||
| 32 | |||
| 33 | private $height; |
||
| 34 | |||
| 35 | private $upscale; |
||
| 36 | |||
| 37 | private $aspectMode; |
||
| 38 | |||
| 39 | private $twoPass; |
||
| 40 | |||
| 41 | private $videoBitrate; |
||
| 42 | |||
| 43 | private $fps; |
||
| 44 | |||
| 45 | private $keyframeInterval; |
||
| 46 | |||
| 47 | private $keyframeRate; |
||
| 48 | |||
| 49 | private $audioBitrate; |
||
| 50 | |||
| 51 | private $audioSampleRate; |
||
| 52 | |||
| 53 | private $audioChannels; |
||
| 54 | |||
| 55 | private $clipLength; |
||
| 56 | |||
| 57 | private $clipOffset; |
||
| 58 | |||
| 59 | private $frameCount; |
||
| 60 | |||
| 61 | private $command; |
||
| 62 | |||
| 63 | private $createdAt; |
||
| 64 | |||
| 65 | private $updatedAt; |
||
| 66 | |||
| 67 | public function getId() |
||
| 71 | |||
| 72 | public function setId($id) |
||
| 76 | |||
| 77 | public function getTitle() |
||
| 81 | |||
| 82 | public function setTitle($title) |
||
| 86 | |||
| 87 | public function getName() |
||
| 91 | |||
| 92 | public function setName($name) |
||
| 96 | |||
| 97 | public function getPresetName() |
||
| 101 | |||
| 102 | public function setPresetName($presetName) |
||
| 106 | |||
| 107 | public function getExtname() |
||
| 111 | |||
| 112 | public function setExtname($extname) |
||
| 116 | |||
| 117 | public function getWidth() |
||
| 121 | |||
| 122 | public function setWidth($width) |
||
| 126 | |||
| 127 | public function getHeight() |
||
| 131 | |||
| 132 | public function setHeight($height) |
||
| 136 | |||
| 137 | public function getUpscale() |
||
| 141 | |||
| 142 | public function setUpscale($upscale) |
||
| 146 | |||
| 147 | public function getAspectMode() |
||
| 151 | |||
| 152 | public function setAspectMode($aspectMode) |
||
| 156 | |||
| 157 | public function getTwoPass() |
||
| 161 | |||
| 162 | public function setTwoPass($twoPass) |
||
| 166 | |||
| 167 | public function getVideoBitrate() |
||
| 171 | |||
| 172 | public function setVideoBitrate($videoBitrate) |
||
| 176 | |||
| 177 | public function getFps() |
||
| 181 | |||
| 182 | public function setFps($fps) |
||
| 186 | |||
| 187 | public function getKeyframeInterval() |
||
| 191 | |||
| 192 | public function setKeyframeInterval($keyframeInterval) |
||
| 196 | |||
| 197 | public function getKeyframeRate() |
||
| 201 | |||
| 202 | public function setKeyframeRate($keyframeRate) |
||
| 206 | |||
| 207 | public function getAudioBitrate() |
||
| 211 | |||
| 212 | public function setAudioBitrate($audioBitrate) |
||
| 216 | |||
| 217 | public function getAudioSampleRate() |
||
| 221 | |||
| 222 | public function setAudioSampleRate($audioSampleRate) |
||
| 226 | |||
| 227 | public function getAudioChannels() |
||
| 231 | |||
| 232 | public function setAudioChannels($audioChannels) |
||
| 236 | |||
| 237 | public function getClipLength() |
||
| 241 | |||
| 242 | public function setClipLength($clipLength) |
||
| 246 | |||
| 247 | public function getClipOffset() |
||
| 251 | |||
| 252 | public function setClipOffset($clipOffset) |
||
| 256 | |||
| 257 | public function getFrameCount() |
||
| 261 | |||
| 262 | public function setFrameCount($frameCount) |
||
| 266 | |||
| 267 | public function getCommand() |
||
| 271 | |||
| 272 | public function setCommand($command) |
||
| 276 | |||
| 277 | public function getCreatedAt() |
||
| 281 | |||
| 282 | public function setCreatedAt($createdAt) |
||
| 286 | |||
| 287 | public function getUpdatedAt() |
||
| 291 | |||
| 292 | public function setUpdatedAt($updatedAt) |
||
| 296 | } |
||
| 297 |