| Total Complexity | 41 |
| Total Lines | 212 |
| Duplicated Lines | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
Complex classes like CustomEntityManager 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 CustomEntityManager, and based on these observations, apply Extract Interface, too.
| 1 | <?php |
||
| 11 | class CustomEntityManager implements EntityManagerInterface |
||
| 12 | { |
||
| 13 | public function getCache() : void |
||
| 14 | { |
||
| 15 | // TODO: Implement getCache() method. |
||
| 16 | } |
||
| 17 | |||
| 18 | public function getConnection() |
||
| 19 | { |
||
| 20 | return new class ($this) extends Connection { |
||
| 21 | /** @var CustomEntityManager */ |
||
| 22 | private $em; |
||
| 23 | |||
| 24 | public function __construct(CustomEntityManager $em) |
||
| 25 | { |
||
| 26 | $this->em = $em; |
||
| 27 | } |
||
| 28 | |||
| 29 | public function getEm() |
||
| 30 | { |
||
| 31 | return $this->em; |
||
| 32 | } |
||
| 33 | }; |
||
| 34 | } |
||
| 35 | |||
| 36 | public function getExpressionBuilder() : void |
||
| 37 | { |
||
| 38 | // TODO: Implement getExpressionBuilder() method. |
||
| 39 | } |
||
| 40 | |||
| 41 | public function beginTransaction() : void |
||
| 42 | { |
||
| 43 | // TODO: Implement beginTransaction() method. |
||
| 44 | } |
||
| 45 | |||
| 46 | public function transactional($func) : void |
||
| 47 | { |
||
| 48 | // TODO: Implement transactional() method. |
||
| 49 | } |
||
| 50 | |||
| 51 | public function commit() : void |
||
| 52 | { |
||
| 53 | // TODO: Implement commit() method. |
||
| 54 | } |
||
| 55 | |||
| 56 | public function rollback() : void |
||
| 57 | { |
||
| 58 | // TODO: Implement rollback() method. |
||
| 59 | } |
||
| 60 | |||
| 61 | public function createQuery($dql = '') : void |
||
| 62 | { |
||
| 63 | // TODO: Implement createQuery() method. |
||
| 64 | } |
||
| 65 | |||
| 66 | public function createNamedQuery($name) : void |
||
| 67 | { |
||
| 68 | // TODO: Implement createNamedQuery() method. |
||
| 69 | } |
||
| 70 | |||
| 71 | public function createNativeQuery($sql, ResultSetMapping $rsm) : void |
||
| 72 | { |
||
| 73 | // TODO: Implement createNativeQuery() method. |
||
| 74 | } |
||
| 75 | |||
| 76 | public function createNamedNativeQuery($name) : void |
||
| 77 | { |
||
| 78 | // TODO: Implement createNamedNativeQuery() method. |
||
| 79 | } |
||
| 80 | |||
| 81 | public function createQueryBuilder() : void |
||
| 82 | { |
||
| 83 | // TODO: Implement createQueryBuilder() method. |
||
| 84 | } |
||
| 85 | |||
| 86 | public function getReference($entityName, $id) : void |
||
| 87 | { |
||
| 88 | // TODO: Implement getReference() method. |
||
| 89 | } |
||
| 90 | |||
| 91 | public function getPartialReference($entityName, $identifier) : void |
||
| 92 | { |
||
| 93 | // TODO: Implement getPartialReference() method. |
||
| 94 | } |
||
| 95 | |||
| 96 | public function close() : void |
||
| 97 | { |
||
| 98 | // TODO: Implement close() method. |
||
| 99 | } |
||
| 100 | |||
| 101 | public function copy($entity, $deep = false) : void |
||
| 102 | { |
||
| 103 | // TODO: Implement copy() method. |
||
| 104 | } |
||
| 105 | |||
| 106 | public function lock($entity, $lockMode, $lockVersion = null) : void |
||
| 107 | { |
||
| 108 | // TODO: Implement lock() method. |
||
| 109 | } |
||
| 110 | |||
| 111 | public function getEventManager() : void |
||
| 112 | { |
||
| 113 | // TODO: Implement getEventManager() method. |
||
| 114 | } |
||
| 115 | |||
| 116 | public function getConfiguration() : void |
||
| 117 | { |
||
| 118 | // TODO: Implement getConfiguration() method. |
||
| 119 | } |
||
| 120 | |||
| 121 | public function isOpen() : void |
||
| 122 | { |
||
| 123 | // TODO: Implement isOpen() method. |
||
| 124 | } |
||
| 125 | |||
| 126 | public function getUnitOfWork() : void |
||
| 127 | { |
||
| 128 | // TODO: Implement getUnitOfWork() method. |
||
| 129 | } |
||
| 130 | |||
| 131 | public function getHydrator($hydrationMode) : void |
||
| 132 | { |
||
| 133 | // TODO: Implement getHydrator() method. |
||
| 134 | } |
||
| 135 | |||
| 136 | public function newHydrator($hydrationMode) : void |
||
| 137 | { |
||
| 138 | // TODO: Implement newHydrator() method. |
||
| 139 | } |
||
| 140 | |||
| 141 | public function getProxyFactory() : void |
||
| 142 | { |
||
| 143 | // TODO: Implement getProxyFactory() method. |
||
| 144 | } |
||
| 145 | |||
| 146 | public function getFilters() : void |
||
| 147 | { |
||
| 148 | // TODO: Implement getFilters() method. |
||
| 149 | } |
||
| 150 | |||
| 151 | public function isFiltersStateClean() : void |
||
| 152 | { |
||
| 153 | // TODO: Implement isFiltersStateClean() method. |
||
| 154 | } |
||
| 155 | |||
| 156 | public function hasFilters() : void |
||
| 157 | { |
||
| 158 | // TODO: Implement hasFilters() method. |
||
| 159 | } |
||
| 160 | |||
| 161 | public function find($className, $id) : void |
||
| 162 | { |
||
| 163 | // TODO: Implement find() method. |
||
| 164 | } |
||
| 165 | |||
| 166 | public function persist($object) : void |
||
| 167 | { |
||
| 168 | // TODO: Implement persist() method. |
||
| 169 | } |
||
| 170 | |||
| 171 | public function remove($object) : void |
||
| 172 | { |
||
| 173 | // TODO: Implement remove() method. |
||
| 174 | } |
||
| 175 | |||
| 176 | public function merge($object) : void |
||
| 177 | { |
||
| 178 | // TODO: Implement merge() method. |
||
| 179 | } |
||
| 180 | |||
| 181 | public function clear($objectName = null) : void |
||
| 182 | { |
||
| 183 | // TODO: Implement clear() method. |
||
| 184 | } |
||
| 185 | |||
| 186 | public function detach($object) : void |
||
| 187 | { |
||
| 188 | // TODO: Implement detach() method. |
||
| 189 | } |
||
| 190 | |||
| 191 | public function refresh($object) : void |
||
| 192 | { |
||
| 193 | // TODO: Implement refresh() method. |
||
| 194 | } |
||
| 195 | |||
| 196 | public function flush() : void |
||
| 197 | { |
||
| 198 | // TODO: Implement flush() method. |
||
| 199 | } |
||
| 200 | |||
| 201 | public function getRepository($className) : void |
||
| 202 | { |
||
| 203 | // TODO: Implement getRepository() method. |
||
| 204 | } |
||
| 205 | |||
| 206 | public function getMetadataFactory() : void |
||
| 207 | { |
||
| 208 | // TODO: Implement getMetadataFactory() method. |
||
| 209 | } |
||
| 210 | |||
| 211 | public function initializeObject($obj) : void |
||
| 212 | { |
||
| 213 | // TODO: Implement initializeObject() method. |
||
| 214 | } |
||
| 215 | |||
| 216 | public function contains($object) : void |
||
| 218 | // TODO: Implement contains() method. |
||
| 219 | } |
||
| 220 | |||
| 221 | public function getClassMetadata($className) : void |
||
| 222 | { |
||
| 223 | } |
||
| 224 | } |
||
| 225 |