Complex classes like JWKFactory 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 JWKFactory, and based on these observations, apply Extract Interface, too.
| 1 | <?php | ||
| 32 | final class JWKFactory implements JWKFactoryInterface | ||
| 33 | { | ||
| 34 | /** | ||
| 35 |      * {@inheritdoc} | ||
| 36 | */ | ||
| 37 | public static function createPublicKeySet(JWKSetInterface $jwkset) | ||
| 41 | |||
| 42 | /** | ||
| 43 |      * {@inheritdoc} | ||
| 44 | */ | ||
| 45 | public static function createKeySets(array $jwksets = []) | ||
| 49 | |||
| 50 | /** | ||
| 51 |      * {@inheritdoc} | ||
| 52 | */ | ||
| 53 | public static function createStorableKey($filename, array $parameters) | ||
| 57 | |||
| 58 | /** | ||
| 59 |      * {@inheritdoc} | ||
| 60 | */ | ||
| 61 | public static function createRotatableKey($filename, array $parameters, $ttl) | ||
| 65 | |||
| 66 | /** | ||
| 67 |      * {@inheritdoc} | ||
| 68 | */ | ||
| 69 | public static function createRotatableKeySet($filename, array $parameters, $nb_keys, $ttl) | ||
| 73 | |||
| 74 | /** | ||
| 75 |      * {@inheritdoc} | ||
| 76 | */ | ||
| 77 | public static function createStorableKeySet($filename, array $parameters, $nb_keys) | ||
| 81 | |||
| 82 | /** | ||
| 83 |      * {@inheritdoc} | ||
| 84 | */ | ||
| 85 | public static function createKey(array $config) | ||
| 95 | |||
| 96 | /** | ||
| 97 |      * {@inheritdoc} | ||
| 98 | */ | ||
| 99 | public static function createRSAKey(array $values) | ||
| 121 | |||
| 122 | /** | ||
| 123 |      * {@inheritdoc} | ||
| 124 | */ | ||
| 125 | public static function createECKey(array $values) | ||
| 146 | |||
| 147 | /** | ||
| 148 |      * {@inheritdoc} | ||
| 149 | */ | ||
| 150 | public static function createOctKey(array $values) | ||
| 166 | |||
| 167 | /** | ||
| 168 |      * {@inheritdoc} | ||
| 169 | */ | ||
| 170 | public static function createOKPKey(array $values) | ||
| 201 | |||
| 202 | /** | ||
| 203 |      * {@inheritdoc} | ||
| 204 | */ | ||
| 205 | public static function createNoneKey(array $values) | ||
| 218 | |||
| 219 | /** | ||
| 220 | * @param string $value | ||
| 221 | * | ||
| 222 | * @return string | ||
| 223 | */ | ||
| 224 | private static function encodeValue($value) | ||
| 230 | |||
| 231 | /** | ||
| 232 | * @param string $value | ||
| 233 | * | ||
| 234 | * @return string | ||
| 235 | */ | ||
| 236 | private static function convertDecToBin($value) | ||
| 242 | |||
| 243 | /** | ||
| 244 | * @param string $curve | ||
| 245 | * | ||
| 246 | * @throws \InvalidArgumentException | ||
| 247 | * | ||
| 248 | * @return string | ||
| 249 | */ | ||
| 250 | private static function getNistName($curve) | ||
| 263 | |||
| 264 | /** | ||
| 265 |      * {@inheritdoc} | ||
| 266 | */ | ||
| 267 | public static function createFromValues(array $values) | ||
| 275 | |||
| 276 | /** | ||
| 277 |      * {@inheritdoc} | ||
| 278 | */ | ||
| 279 | public static function createFromCertificateFile($file, array $additional_values = []) | ||
| 286 | |||
| 287 | /** | ||
| 288 |      * {@inheritdoc} | ||
| 289 | */ | ||
| 290 | public static function createFromCertificate($certificate, array $additional_values = []) | ||
| 297 | |||
| 298 | /** | ||
| 299 |      * {@inheritdoc} | ||
| 300 | */ | ||
| 301 | public static function createFromX509Resource($res, array $additional_values = []) | ||
| 308 | |||
| 309 | /** | ||
| 310 |      * {@inheritdoc} | ||
| 311 | */ | ||
| 312 | public static function createFromKeyFile($file, $password = null, array $additional_values = []) | ||
| 319 | |||
| 320 | /** | ||
| 321 |      * {@inheritdoc} | ||
| 322 | */ | ||
| 323 | public static function createFromKey($key, $password = null, array $additional_values = []) | ||
| 330 | |||
| 331 | /** | ||
| 332 |      * {@inheritdoc} | ||
| 333 | */ | ||
| 334 | public static function createFromJKU($jku, $allow_unsecured_connection = false, CacheItemPoolInterface $cache = null, $ttl = 604800) | ||
| 342 | |||
| 343 | /** | ||
| 344 |      * {@inheritdoc} | ||
| 345 | */ | ||
| 346 | public static function createFromX5U($x5u, $allow_unsecured_connection = false, CacheItemPoolInterface $cache = null, $ttl = 604800) | ||
| 362 | |||
| 363 | /** | ||
| 364 | * @param string $url | ||
| 365 | * @param bool $allow_unsecured_connection | ||
| 366 | * @param \Psr\Cache\CacheItemPoolInterface|null $cache | ||
| 367 | * @param int|null $ttl | ||
| 368 | * | ||
| 369 | * @return array | ||
| 370 | */ | ||
| 371 | private static function getContent($url, $allow_unsecured_connection, CacheItemPoolInterface $cache = null, $ttl = 604800) | ||
| 393 | |||
| 394 | /** | ||
| 395 |      * {@inheritdoc} | ||
| 396 | */ | ||
| 397 | public static function createFromX5C(array $x5c, array $additional_values = []) | ||
| 404 | |||
| 405 | /** | ||
| 406 |      * {@inheritdoc} | ||
| 407 | */ | ||
| 408 | public static function createFromKeySet(JWKSetInterface $jwk_set, $key_index) | ||
| 414 | |||
| 415 | /** | ||
| 416 | * @param string $url | ||
| 417 | * @param bool $allow_unsecured_connection | ||
| 418 | * | ||
| 419 | * @throws \InvalidArgumentException | ||
| 420 | * | ||
| 421 | * @return array | ||
| 422 | */ | ||
| 423 | private static function downloadContent($url, $allow_unsecured_connection) | ||
| 457 | } | ||
| 458 |