Complex classes like PersistentCollectionAdapter 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 PersistentCollectionAdapter, and based on these observations, apply Extract Interface, too.
| 1 | <?php  | 
            ||
| 22 | abstract class PersistentCollectionAdapter extends PersistentCollection implements CollectionInterface  | 
            ||
| 23 | { | 
            ||
| 24 | /**  | 
            ||
| 25 | * @var PersistentCollection  | 
            ||
| 26 | */  | 
            ||
| 27 | protected $collection;  | 
            ||
| 28 | |||
| 29 | /**  | 
            ||
| 30 | * @param PersistentCollection $collection  | 
            ||
| 31 | */  | 
            ||
| 32 | public function __construct(PersistentCollection $collection)  | 
            ||
| 36 | |||
| 37 | /**  | 
            ||
| 38 |      * {@inheritdoc} | 
            ||
| 39 | */  | 
            ||
| 40 | public function setDocumentManager(DocumentManager $dm)  | 
            ||
| 44 | |||
| 45 | /**  | 
            ||
| 46 |      * {@inheritdoc} | 
            ||
| 47 | */  | 
            ||
| 48 | public function setMongoData(array $mongoData)  | 
            ||
| 52 | |||
| 53 | /**  | 
            ||
| 54 |      * {@inheritdoc} | 
            ||
| 55 | */  | 
            ||
| 56 | public function getMongoData()  | 
            ||
| 60 | |||
| 61 | /**  | 
            ||
| 62 |      * {@inheritdoc} | 
            ||
| 63 | */  | 
            ||
| 64 | public function setHints(array $hints)  | 
            ||
| 68 | |||
| 69 | /**  | 
            ||
| 70 |      * {@inheritdoc} | 
            ||
| 71 | */  | 
            ||
| 72 | public function getHints()  | 
            ||
| 76 | |||
| 77 | /**  | 
            ||
| 78 |      * {@inheritdoc} | 
            ||
| 79 | */  | 
            ||
| 80 | public function initialize()  | 
            ||
| 84 | |||
| 85 | /**  | 
            ||
| 86 |      * {@inheritdoc} | 
            ||
| 87 | */  | 
            ||
| 88 | public function isDirty()  | 
            ||
| 92 | |||
| 93 | /**  | 
            ||
| 94 |      * {@inheritdoc} | 
            ||
| 95 | */  | 
            ||
| 96 | public function setDirty($dirty)  | 
            ||
| 100 | |||
| 101 | /**  | 
            ||
| 102 |      * {@inheritdoc} | 
            ||
| 103 | */  | 
            ||
| 104 | public function setOwner($document, array $mapping)  | 
            ||
| 108 | |||
| 109 | /**  | 
            ||
| 110 |      * {@inheritdoc} | 
            ||
| 111 | */  | 
            ||
| 112 | public function takeSnapshot()  | 
            ||
| 116 | |||
| 117 | /**  | 
            ||
| 118 |      * {@inheritdoc} | 
            ||
| 119 | */  | 
            ||
| 120 | public function clearSnapshot()  | 
            ||
| 124 | |||
| 125 | /**  | 
            ||
| 126 |      * {@inheritdoc} | 
            ||
| 127 | */  | 
            ||
| 128 | public function getSnapshot()  | 
            ||
| 132 | |||
| 133 | /**  | 
            ||
| 134 |      * {@inheritdoc} | 
            ||
| 135 | */  | 
            ||
| 136 | public function getDeleteDiff()  | 
            ||
| 140 | |||
| 141 | /**  | 
            ||
| 142 |      * {@inheritdoc} | 
            ||
| 143 | */  | 
            ||
| 144 | public function getDeletedDocuments()  | 
            ||
| 148 | |||
| 149 | /**  | 
            ||
| 150 |      * {@inheritdoc} | 
            ||
| 151 | */  | 
            ||
| 152 | public function getInsertDiff()  | 
            ||
| 156 | |||
| 157 | /**  | 
            ||
| 158 |      * {@inheritdoc} | 
            ||
| 159 | */  | 
            ||
| 160 | public function getOwner()  | 
            ||
| 164 | |||
| 165 | /**  | 
            ||
| 166 |      * {@inheritdoc} | 
            ||
| 167 | */  | 
            ||
| 168 | public function getMapping()  | 
            ||
| 172 | |||
| 173 | /**  | 
            ||
| 174 |      * {@inheritdoc} | 
            ||
| 175 | */  | 
            ||
| 176 | public function getTypeClass()  | 
            ||
| 180 | |||
| 181 | /**  | 
            ||
| 182 |      * {@inheritdoc} | 
            ||
| 183 | */  | 
            ||
| 184 | public function setInitialized($bool)  | 
            ||
| 188 | |||
| 189 | /**  | 
            ||
| 190 |      * {@inheritdoc} | 
            ||
| 191 | */  | 
            ||
| 192 | public function isInitialized()  | 
            ||
| 196 | |||
| 197 | /**  | 
            ||
| 198 |      * {@inheritdoc} | 
            ||
| 199 | */  | 
            ||
| 200 | public function first()  | 
            ||
| 204 | |||
| 205 | /**  | 
            ||
| 206 |      * {@inheritdoc} | 
            ||
| 207 | */  | 
            ||
| 208 | public function last()  | 
            ||
| 212 | |||
| 213 | /**  | 
            ||
| 214 |      * {@inheritdoc} | 
            ||
| 215 | */  | 
            ||
| 216 | public function remove($key)  | 
            ||
| 220 | |||
| 221 | /**  | 
            ||
| 222 |      * {@inheritdoc} | 
            ||
| 223 | */  | 
            ||
| 224 | public function removeElement($element)  | 
            ||
| 228 | |||
| 229 | /**  | 
            ||
| 230 |      * {@inheritdoc} | 
            ||
| 231 | */  | 
            ||
| 232 | public function containsKey($key)  | 
            ||
| 236 | |||
| 237 | /**  | 
            ||
| 238 |      * {@inheritdoc} | 
            ||
| 239 | */  | 
            ||
| 240 | public function contains($element)  | 
            ||
| 244 | |||
| 245 | /**  | 
            ||
| 246 |      * {@inheritdoc} | 
            ||
| 247 | */  | 
            ||
| 248 | public function exists(\Closure $p)  | 
            ||
| 252 | |||
| 253 | /**  | 
            ||
| 254 |      * {@inheritdoc} | 
            ||
| 255 | */  | 
            ||
| 256 | public function indexOf($element)  | 
            ||
| 260 | |||
| 261 | /**  | 
            ||
| 262 |      * {@inheritdoc} | 
            ||
| 263 | */  | 
            ||
| 264 | public function get($key)  | 
            ||
| 268 | |||
| 269 | /**  | 
            ||
| 270 |      * {@inheritdoc} | 
            ||
| 271 | */  | 
            ||
| 272 | public function getKeys()  | 
            ||
| 276 | |||
| 277 | /**  | 
            ||
| 278 |      * {@inheritdoc} | 
            ||
| 279 | */  | 
            ||
| 280 | public function getValues()  | 
            ||
| 284 | |||
| 285 | /**  | 
            ||
| 286 |      * {@inheritdoc} | 
            ||
| 287 | */  | 
            ||
| 288 | public function count()  | 
            ||
| 292 | |||
| 293 | /**  | 
            ||
| 294 |      * {@inheritdoc} | 
            ||
| 295 | */  | 
            ||
| 296 | public function set($key, $value)  | 
            ||
| 300 | |||
| 301 | /**  | 
            ||
| 302 |      * {@inheritdoc} | 
            ||
| 303 | */  | 
            ||
| 304 | public function add($value)  | 
            ||
| 308 | |||
| 309 | /**  | 
            ||
| 310 |      * {@inheritdoc} | 
            ||
| 311 | */  | 
            ||
| 312 | public function isEmpty()  | 
            ||
| 316 | |||
| 317 | /**  | 
            ||
| 318 |      * {@inheritdoc} | 
            ||
| 319 | */  | 
            ||
| 320 | public function getIterator()  | 
            ||
| 324 | |||
| 325 | /**  | 
            ||
| 326 |      * {@inheritdoc} | 
            ||
| 327 | */  | 
            ||
| 328 | public function map(\Closure $func)  | 
            ||
| 332 | |||
| 333 | /**  | 
            ||
| 334 |      * {@inheritdoc} | 
            ||
| 335 | */  | 
            ||
| 336 | public function filter(\Closure $p)  | 
            ||
| 340 | |||
| 341 | /**  | 
            ||
| 342 |      * {@inheritdoc} | 
            ||
| 343 | */  | 
            ||
| 344 | public function forAll(\Closure $p)  | 
            ||
| 348 | |||
| 349 | /**  | 
            ||
| 350 |      * {@inheritdoc} | 
            ||
| 351 | */  | 
            ||
| 352 | public function partition(\Closure $p)  | 
            ||
| 356 | |||
| 357 | /**  | 
            ||
| 358 |      * {@inheritdoc} | 
            ||
| 359 | */  | 
            ||
| 360 | public function toArray()  | 
            ||
| 364 | |||
| 365 | /**  | 
            ||
| 366 |      * {@inheritdoc} | 
            ||
| 367 | */  | 
            ||
| 368 | public function clear()  | 
            ||
| 372 | |||
| 373 | /**  | 
            ||
| 374 |      * {@inheritdoc} | 
            ||
| 375 | */  | 
            ||
| 376 | public function slice($offset, $length = null)  | 
            ||
| 380 | |||
| 381 | /**  | 
            ||
| 382 |      * {@inheritdoc} | 
            ||
| 383 | */  | 
            ||
| 384 | public function __sleep()  | 
            ||
| 388 | |||
| 389 | /**  | 
            ||
| 390 |      * {@inheritdoc} | 
            ||
| 391 | */  | 
            ||
| 392 | public function offsetExists($offset)  | 
            ||
| 396 | |||
| 397 | /**  | 
            ||
| 398 |      * {@inheritdoc} | 
            ||
| 399 | */  | 
            ||
| 400 | public function offsetGet($offset)  | 
            ||
| 404 | |||
| 405 | /**  | 
            ||
| 406 |      * {@inheritdoc} | 
            ||
| 407 | */  | 
            ||
| 408 | public function offsetSet($offset, $value)  | 
            ||
| 412 | |||
| 413 | /**  | 
            ||
| 414 |      * {@inheritdoc} | 
            ||
| 415 | */  | 
            ||
| 416 | public function offsetUnset($offset)  | 
            ||
| 420 | |||
| 421 | /**  | 
            ||
| 422 |      * {@inheritdoc} | 
            ||
| 423 | */  | 
            ||
| 424 | public function key()  | 
            ||
| 428 | |||
| 429 | /**  | 
            ||
| 430 |      * {@inheritdoc} | 
            ||
| 431 | */  | 
            ||
| 432 | public function current()  | 
            ||
| 436 | |||
| 437 | /**  | 
            ||
| 438 |      * {@inheritdoc} | 
            ||
| 439 | */  | 
            ||
| 440 | public function next()  | 
            ||
| 444 | |||
| 445 | /**  | 
            ||
| 446 |      * {@inheritdoc} | 
            ||
| 447 | */  | 
            ||
| 448 | public function unwrap()  | 
            ||
| 452 | |||
| 453 | /**  | 
            ||
| 454 |      * {@inheritdoc} | 
            ||
| 455 | */  | 
            ||
| 456 | public function __clone()  | 
            ||
| 460 | }  | 
            ||
| 461 |