| Total Complexity | 41 |
| Total Lines | 174 |
| 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 |
||
| 15 | } |
||
| 16 | |||
| 17 | public function getConnection() |
||
| 18 | { |
||
| 19 | return new class ($this) extends Connection { |
||
| 20 | /** @var CustomEntityManager */ |
||
| 21 | private $em; |
||
| 22 | |||
| 23 | public function __construct(CustomEntityManager $em) |
||
| 24 | { |
||
| 25 | $this->em = $em; |
||
| 26 | } |
||
| 27 | |||
| 28 | public function getEm() |
||
| 29 | { |
||
| 30 | return $this->em; |
||
| 31 | } |
||
| 32 | }; |
||
| 33 | } |
||
| 34 | |||
| 35 | public function getExpressionBuilder() : void |
||
| 36 | { |
||
| 37 | } |
||
| 38 | |||
| 39 | public function beginTransaction() : void |
||
| 40 | { |
||
| 41 | } |
||
| 42 | |||
| 43 | public function transactional($func) : void |
||
| 44 | { |
||
| 45 | } |
||
| 46 | |||
| 47 | public function commit() : void |
||
| 48 | { |
||
| 49 | } |
||
| 50 | |||
| 51 | public function rollback() : void |
||
| 52 | { |
||
| 53 | } |
||
| 54 | |||
| 55 | public function createQuery($dql = '') : void |
||
| 56 | { |
||
| 57 | } |
||
| 58 | |||
| 59 | public function createNamedQuery($name) : void |
||
| 60 | { |
||
| 61 | } |
||
| 62 | |||
| 63 | public function createNativeQuery($sql, ResultSetMapping $rsm) : void |
||
| 64 | { |
||
| 65 | } |
||
| 66 | |||
| 67 | public function createNamedNativeQuery($name) : void |
||
| 68 | { |
||
| 69 | } |
||
| 70 | |||
| 71 | public function createQueryBuilder() : void |
||
| 72 | { |
||
| 73 | } |
||
| 74 | |||
| 75 | public function getReference($entityName, $id) : void |
||
| 76 | { |
||
| 77 | } |
||
| 78 | |||
| 79 | public function getPartialReference($entityName, $identifier) : void |
||
| 80 | { |
||
| 81 | } |
||
| 82 | |||
| 83 | public function close() : void |
||
| 84 | { |
||
| 85 | } |
||
| 86 | |||
| 87 | public function copy($entity, $deep = false) : void |
||
| 88 | { |
||
| 89 | } |
||
| 90 | |||
| 91 | public function lock($entity, $lockMode, $lockVersion = null) : void |
||
| 92 | { |
||
| 93 | } |
||
| 94 | |||
| 95 | public function getEventManager() : void |
||
| 96 | { |
||
| 97 | } |
||
| 98 | |||
| 99 | public function getConfiguration() : void |
||
| 100 | { |
||
| 101 | } |
||
| 102 | |||
| 103 | public function isOpen() : void |
||
| 104 | { |
||
| 105 | } |
||
| 106 | |||
| 107 | public function getUnitOfWork() : void |
||
| 108 | { |
||
| 109 | } |
||
| 110 | |||
| 111 | public function getHydrator($hydrationMode) : void |
||
| 112 | { |
||
| 113 | } |
||
| 114 | |||
| 115 | public function newHydrator($hydrationMode) : void |
||
| 116 | { |
||
| 117 | } |
||
| 118 | |||
| 119 | public function getProxyFactory() : void |
||
| 120 | { |
||
| 121 | } |
||
| 122 | |||
| 123 | public function getFilters() : void |
||
| 124 | { |
||
| 125 | } |
||
| 126 | |||
| 127 | public function isFiltersStateClean() : void |
||
| 128 | { |
||
| 129 | } |
||
| 130 | |||
| 131 | public function hasFilters() : void |
||
| 132 | { |
||
| 133 | } |
||
| 134 | |||
| 135 | public function find($className, $id) : void |
||
| 136 | { |
||
| 137 | } |
||
| 138 | |||
| 139 | public function persist($object) : void |
||
| 140 | { |
||
| 141 | } |
||
| 142 | |||
| 143 | public function remove($object) : void |
||
| 144 | { |
||
| 145 | } |
||
| 146 | |||
| 147 | public function merge($object) : void |
||
| 148 | { |
||
| 149 | } |
||
| 150 | |||
| 151 | public function clear($objectName = null) : void |
||
| 152 | { |
||
| 153 | } |
||
| 154 | |||
| 155 | public function detach($object) : void |
||
| 156 | { |
||
| 157 | } |
||
| 158 | |||
| 159 | public function refresh($object) : void |
||
| 160 | { |
||
| 161 | } |
||
| 162 | |||
| 163 | public function flush() : void |
||
| 164 | { |
||
| 165 | } |
||
| 166 | |||
| 167 | public function getRepository($className) : void |
||
| 168 | { |
||
| 169 | } |
||
| 170 | |||
| 171 | public function getMetadataFactory() : void |
||
| 172 | { |
||
| 173 | } |
||
| 174 | |||
| 175 | public function initializeObject($obj) : void |
||
| 176 | { |
||
| 177 | } |
||
| 178 | |||
| 179 | public function contains($object) : void |
||
| 181 | } |
||
| 182 | |||
| 183 | public function getClassMetadata($className) : void |
||
| 184 | { |
||
| 185 | } |
||
| 186 | } |
||
| 187 |