Complex classes like PropelBaseModelClass 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. You can also have a look at the cohesion graph to spot any un-connected, or weakly-connected components.
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 PropelBaseModelClass, and based on these observations, apply Extract Interface, too.
| 1 | <?php |
||
| 15 | class PropelBaseModelClass implements \Serializable |
||
| 16 | { |
||
|
|
|||
| 17 | |||
| 18 | public $customFields; |
||
| 19 | |||
| 20 | public $customData; |
||
| 21 | |||
| 22 | public $hasCustomData = false; |
||
| 23 | |||
| 24 | public $entityId; |
||
| 25 | |||
| 26 | private $entities_locale = [ |
||
| 27 | 'product', |
||
| 28 | 'category', |
||
| 29 | 'brand', |
||
| 30 | ]; |
||
| 31 | |||
| 32 | /** |
||
| 33 | * @param MY_Form_validation $validator |
||
| 34 | * @return mixed |
||
| 35 | */ |
||
| 36 | public function validateCustomData($validator) { |
||
| 61 | |||
| 62 | /** |
||
| 63 | * @param string $entityName |
||
| 64 | * @param int $id |
||
| 65 | * @return bool |
||
| 66 | */ |
||
| 67 | public function collectCustomData($entityName, $id) { |
||
| 82 | |||
| 83 | /** |
||
| 84 | * @param int $key |
||
| 85 | * @return bool |
||
| 86 | */ |
||
| 87 | public function curentPostEntitySave($key) { |
||
| 93 | |||
| 94 | public function saveCustomData() { |
||
| 132 | |||
| 133 | /** |
||
| 134 | * @param $attributeName |
||
| 135 | * @return mixed |
||
| 136 | */ |
||
| 137 | public function getLabel($attributeName) { |
||
| 148 | |||
| 149 | /** |
||
| 150 | * @param string $column |
||
| 151 | * @return bool |
||
| 152 | */ |
||
| 153 | public function getVirtual($column) { |
||
| 157 | |||
| 158 | /** |
||
| 159 | * @param string $name |
||
| 160 | * @return bool |
||
| 161 | */ |
||
| 162 | public function getVirtualColumn($name) { |
||
| 170 | |||
| 171 | /** |
||
| 172 | * Convert model attribute(by default Price). e.g. "99.99 $" |
||
| 173 | * |
||
| 174 | * @param string $attributeName Optional. Attribute name to convert. |
||
| 175 | * @access public |
||
| 176 | * @return string |
||
| 177 | */ |
||
| 178 | public function toCurrency($attributeName = 'Price', $cId = null, $convertForTemplate = false) { |
||
| 194 | |||
| 195 | /** |
||
| 196 | * Simple getter. |
||
| 197 | * |
||
| 198 | * @param $name |
||
| 199 | * @return |
||
| 200 | */ |
||
| 201 | public function __get($name) { |
||
| 211 | |||
| 212 | /** |
||
| 213 | * @return CacheProvider |
||
| 214 | */ |
||
| 215 | public function getCache() { |
||
| 219 | |||
| 220 | public function __call($name, $param) { |
||
| 235 | |||
| 236 | public function setVirtualColumn($name, $value) { |
||
| 242 | |||
| 243 | public function preSave(ConnectionInterface $con = null) { |
||
| 246 | |||
| 247 | public function postSave(ConnectionInterface $con = null) { |
||
| 250 | |||
| 251 | public function preInsert(ConnectionInterface $con = null) { |
||
| 254 | |||
| 255 | public function postInsert(ConnectionInterface $con = null) { |
||
| 258 | |||
| 259 | public function preUpdate(ConnectionInterface $con = null) { |
||
| 262 | |||
| 263 | public function postUpdate(ConnectionInterface $con = null) { |
||
| 266 | |||
| 267 | public function postDelete(ConnectionInterface $con = null) { |
||
| 270 | |||
| 271 | public function preDelete(ConnectionInterface $con = null) { |
||
| 274 | |||
| 275 | /** |
||
| 276 | * String representation of object |
||
| 277 | * @link http://php.net/manual/en/serializable.serialize.php |
||
| 278 | * @return string the string representation of the object or null |
||
| 279 | * @since 5.1.0 |
||
| 280 | */ |
||
| 281 | public function serialize() { |
||
| 302 | |||
| 303 | private function prepareToSleep() { |
||
| 313 | |||
| 314 | /** |
||
| 315 | * Constructs the object |
||
| 316 | * @link http://php.net/manual/en/serializable.unserialize.php |
||
| 317 | * @param string $serialized <p> |
||
| 318 | * The string representation of the object. |
||
| 319 | * </p> |
||
| 320 | * @return void |
||
| 321 | * @since 5.1.0 |
||
| 322 | */ |
||
| 323 | public function unserialize($serialized) { |
||
| 333 | |||
| 334 | } |