| Conditions | 24 |
| Paths | > 20000 |
| Total Lines | 94 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.
For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.
Commonly applied refactorings include:
If many parameters/temporary variables are present:
| 1 | <?php |
||
| 35 | public function registerHooksFromClass(string $handler) |
||
| 36 | { |
||
| 37 | if (!class_exists($handler, false)) { |
||
| 38 | throw new \InvalidArgumentException('Plugins must be loaded before registration'); |
||
| 39 | } |
||
| 40 | |||
| 41 | if (is_subclass_of($handler, Hook\AfterMethodCallAnalysisInterface::class)) { |
||
|
|
|||
| 42 | $this->config->after_method_checks[$handler] = $handler; |
||
| 43 | } |
||
| 44 | |||
| 45 | if (is_subclass_of($handler, Hook\AfterFunctionCallAnalysisInterface::class)) { |
||
| 46 | $this->config->after_function_checks[$handler] = $handler; |
||
| 47 | } |
||
| 48 | |||
| 49 | if (is_subclass_of($handler, Hook\AfterEveryFunctionCallAnalysisInterface::class)) { |
||
| 50 | $this->config->after_every_function_checks[$handler] = $handler; |
||
| 51 | } |
||
| 52 | |||
| 53 | if (is_subclass_of($handler, Hook\AfterExpressionAnalysisInterface::class)) { |
||
| 54 | $this->config->after_expression_checks[$handler] = $handler; |
||
| 55 | } |
||
| 56 | |||
| 57 | if (is_subclass_of($handler, Hook\AfterStatementAnalysisInterface::class)) { |
||
| 58 | $this->config->after_statement_checks[$handler] = $handler; |
||
| 59 | } |
||
| 60 | |||
| 61 | if (is_subclass_of($handler, Hook\AfterClassLikeExistenceCheckInterface::class)) { |
||
| 62 | $this->config->after_classlike_exists_checks[$handler] = $handler; |
||
| 63 | } |
||
| 64 | |||
| 65 | if (is_subclass_of($handler, Hook\AfterClassLikeAnalysisInterface::class)) { |
||
| 66 | $this->config->after_classlike_checks[$handler] = $handler; |
||
| 67 | } |
||
| 68 | |||
| 69 | if (is_subclass_of($handler, Hook\AfterClassLikeVisitInterface::class)) { |
||
| 70 | $this->config->after_visit_classlikes[$handler] = $handler; |
||
| 71 | } |
||
| 72 | |||
| 73 | if (is_subclass_of($handler, Hook\AfterCodebasePopulatedInterface::class)) { |
||
| 74 | $this->config->after_codebase_populated[$handler] = $handler; |
||
| 75 | } |
||
| 76 | |||
| 77 | if (is_subclass_of($handler, Hook\PropertyExistenceProviderInterface::class)) { |
||
| 78 | $this->codebase->properties->property_existence_provider->registerClass($handler); |
||
| 79 | } |
||
| 80 | |||
| 81 | if (is_subclass_of($handler, Hook\PropertyVisibilityProviderInterface::class)) { |
||
| 82 | $this->codebase->properties->property_visibility_provider->registerClass($handler); |
||
| 83 | } |
||
| 84 | |||
| 85 | if (is_subclass_of($handler, Hook\PropertyTypeProviderInterface::class)) { |
||
| 86 | $this->codebase->properties->property_type_provider->registerClass($handler); |
||
| 87 | } |
||
| 88 | |||
| 89 | if (is_subclass_of($handler, Hook\MethodExistenceProviderInterface::class)) { |
||
| 90 | $this->codebase->methods->existence_provider->registerClass($handler); |
||
| 91 | } |
||
| 92 | |||
| 93 | if (is_subclass_of($handler, Hook\MethodVisibilityProviderInterface::class)) { |
||
| 94 | $this->codebase->methods->visibility_provider->registerClass($handler); |
||
| 95 | } |
||
| 96 | |||
| 97 | if (is_subclass_of($handler, Hook\MethodReturnTypeProviderInterface::class)) { |
||
| 98 | $this->codebase->methods->return_type_provider->registerClass($handler); |
||
| 99 | } |
||
| 100 | |||
| 101 | if (is_subclass_of($handler, Hook\MethodParamsProviderInterface::class)) { |
||
| 102 | $this->codebase->methods->params_provider->registerClass($handler); |
||
| 103 | } |
||
| 104 | |||
| 105 | if (is_subclass_of($handler, Hook\FunctionExistenceProviderInterface::class)) { |
||
| 106 | $this->codebase->functions->existence_provider->registerClass($handler); |
||
| 107 | } |
||
| 108 | |||
| 109 | if (is_subclass_of($handler, Hook\FunctionParamsProviderInterface::class)) { |
||
| 110 | $this->codebase->functions->params_provider->registerClass($handler); |
||
| 111 | } |
||
| 112 | |||
| 113 | if (is_subclass_of($handler, Hook\FunctionReturnTypeProviderInterface::class)) { |
||
| 114 | $this->codebase->functions->return_type_provider->registerClass($handler); |
||
| 115 | } |
||
| 116 | |||
| 117 | if (is_subclass_of($handler, Hook\AfterAnalysisInterface::class)) { |
||
| 118 | $this->config->after_analysis[$handler] = $handler; |
||
| 119 | } |
||
| 120 | |||
| 121 | if (is_subclass_of($handler, Hook\StringInterpreterInterface::class)) { |
||
| 122 | $this->config->string_interpreters[$handler] = $handler; |
||
| 123 | } |
||
| 124 | |||
| 125 | if (is_subclass_of($handler, Hook\AfterFunctionLikeAnalysisInterface::class)) { |
||
| 126 | $this->config->after_functionlike_checks[$handler] = $handler; |
||
| 127 | } |
||
| 128 | } |
||
| 129 | } |
||
| 130 |