Complex classes like CachedParameterResolver 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 CachedParameterResolver, and based on these observations, apply Extract Interface, too.
1 | <?php |
||
19 | class CachedParameterResolver implements ParameterResolverInterface |
||
20 | { |
||
21 | /** |
||
22 | * @var ParameterResolverInterface |
||
23 | */ |
||
24 | private $parameterResolver; |
||
25 | |||
26 | /** |
||
27 | * @var mixed[] |
||
28 | */ |
||
29 | private $cache = []; |
||
30 | |||
31 | /** |
||
32 | * @param ParameterResolverInterface $parameterResolver |
||
33 | */ |
||
34 | 29 | public function __construct(ParameterResolverInterface $parameterResolver) |
|
38 | |||
39 | /** |
||
40 | * {@inheritdoc} |
||
41 | */ |
||
42 | 1 | public function resolveApi() |
|
48 | |||
49 | /** |
||
50 | * {@inheritdoc} |
||
51 | */ |
||
52 | 2 | public function resolveCriteria($mandatory = false) |
|
64 | |||
65 | /** |
||
66 | * {@inheritdoc} |
||
67 | */ |
||
68 | 1 | public function resolveCurrentPage() |
|
74 | |||
75 | /** |
||
76 | * {@inheritdoc} |
||
77 | */ |
||
78 | 1 | public function resolveForm(ResourceInterface $resource) |
|
84 | |||
85 | /** |
||
86 | * {@inheritdoc} |
||
87 | */ |
||
88 | 1 | public function resolveGrid(ResourceInterface $resource) |
|
94 | |||
95 | /** |
||
96 | * {@inheritdoc} |
||
97 | */ |
||
98 | 1 | public function resolveHateoas() |
|
104 | |||
105 | /** |
||
106 | * {@inheritdoc} |
||
107 | */ |
||
108 | 1 | public function resolveLocationRoute() |
|
114 | |||
115 | /** |
||
116 | * {@inheritdoc} |
||
117 | */ |
||
118 | 1 | public function resolveLocationRouteParameters($object) |
|
124 | |||
125 | /** |
||
126 | * {@inheritdoc} |
||
127 | */ |
||
128 | 1 | public function resolveMaxPerPage() |
|
134 | |||
135 | /** |
||
136 | * {@inheritdoc} |
||
137 | */ |
||
138 | 1 | public function resolveRedirectRoute() |
|
144 | |||
145 | /** |
||
146 | * {@inheritdoc} |
||
147 | */ |
||
148 | 1 | public function resolveRedirectRouteParameters($object = null, $forwardParameters = false) |
|
167 | |||
168 | /** |
||
169 | * @return bool |
||
170 | */ |
||
171 | 1 | public function resolveRedirectRouteParametersForward() |
|
177 | |||
178 | /** |
||
179 | * {@inheritdoc} |
||
180 | */ |
||
181 | 1 | public function resolveRepositoryMethod($action) |
|
187 | |||
188 | /** |
||
189 | * {@inheritdoc} |
||
190 | */ |
||
191 | 1 | public function resolveSerializerGroups() |
|
197 | |||
198 | /** |
||
199 | * {@inheritdoc} |
||
200 | */ |
||
201 | 1 | public function resolveSerializerNull() |
|
207 | |||
208 | /** |
||
209 | * {@inheritdoc} |
||
210 | */ |
||
211 | 1 | public function resolveSorting() |
|
217 | |||
218 | /** |
||
219 | * {@inheritdoc} |
||
220 | */ |
||
221 | 1 | public function resolveStatusCode($statusCode) |
|
227 | |||
228 | /** |
||
229 | * {@inheritdoc} |
||
230 | */ |
||
231 | 1 | public function resolveTemplate() |
|
237 | |||
238 | /** |
||
239 | * {@inheritdoc} |
||
240 | */ |
||
241 | 1 | public function resolveThemes() |
|
247 | |||
248 | /** |
||
249 | * {@inheritdoc} |
||
250 | */ |
||
251 | 1 | public function resolveTranslationDomain() |
|
257 | |||
258 | /** |
||
259 | * {@inheritdoc} |
||
260 | */ |
||
261 | 1 | public function resolveValidationGroups() |
|
267 | |||
268 | /** |
||
269 | * {@inheritdoc} |
||
270 | */ |
||
271 | 1 | public function resolveVoter() |
|
277 | } |
||
278 |